CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Summat
Sender:AtskaFin
Submission time:2020-09-27 20:16:22 +0300
Language:C++17
Status:READY
Result:12
Feedback
groupverdictscore
#1ACCEPTED12
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2, 3details
#2ACCEPTED0.01 s1, 2, 3details
#3ACCEPTED0.01 s1, 2, 3details
#4ACCEPTED0.01 s1, 2, 3details
#5ACCEPTED0.01 s1, 2, 3details
#6ACCEPTED0.01 s2, 3details
#7--2, 3details
#8--2, 3details
#9--2, 3details
#10--2, 3details
#11ACCEPTED0.01 s3details
#12--3details
#13--3details
#14--3details
#15--3details

Code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v;
vector<int> sum_v;
vector<int> input_sum_v;
int n;
bool ratkaisuLoydetty = false;

void tulostaRatkaisu() {
  for (int x : v) {
    cout << x << " ";
  }

  cout << "\n";
}

bool test() {
  int index_t = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      sum_v[index_t++] = v[i]+v[j];
    }
  }

  sort(sum_v.begin(), sum_v.end());

  return input_sum_v == sum_v;
}

void haku(int i, int edellinen) {
  if (ratkaisuLoydetty) return;

  if (i == n) {
    bool isAnswer = test();

    if (isAnswer) {
      tulostaRatkaisu();
      ratkaisuLoydetty = true;
    }
    return;
  }

  for (int j = edellinen; j <= n; j++) {
    v[i] = j;
    haku(i+1, j);
    if (ratkaisuLoydetty) return;
  }
}

int main() {
  cin >> n;

  int len = n * (n - 1) / 2;
  input_sum_v.resize(len);

  for (int i = 0; i < len; i++) cin >> input_sum_v[i];

  sort(input_sum_v.begin(), input_sum_v.end());

  v.resize(n);
  sum_v.resize(len);

  haku(0, 1);
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
2 2 2 2 2 2 2 2 2 2

correct output
1 1 1 1 1 

user output
1 1 1 1 1 

Test 2

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
3 4 5 5 6 6 7 7 8 9

correct output
1 2 3 4 5 

user output
1 2 3 4 5 

Test 3

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
5 6 6 6 9 9 9 10 10 10

correct output
1 4 5 5 5 

user output
1 4 5 5 5 

Test 4

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
2 3 3 6 6 6 6 7 7 10

correct output
1 1 2 5 5 

user output
1 1 2 5 5 

Test 5

Group: 1, 2, 3

Verdict: ACCEPTED

input
5
4 5 5 5 5 6 6 6 7 7

correct output
2 2 3 3 4 

user output
2 2 3 3 4 

Test 6

Group: 2, 3

Verdict: ACCEPTED

input
20
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 7

Group: 2, 3

Verdict:

input
20
3 4 5 5 6 6 7 7 7 8 8 8 9 9 9 ...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 8

Group: 2, 3

Verdict:

input
20
52 55 55 57 62 62 63 64 66 71 ...

correct output
1 51 54 54 56 61 61 62 63 65 7...

user output
(empty)

Test 9

Group: 2, 3

Verdict:

input
20
25 30 31 32 36 39 40 41 45 45 ...

correct output
8 17 22 23 24 28 43 50 53 55 6...

user output
(empty)

Test 10

Group: 2, 3

Verdict:

input
20
9 10 14 17 17 20 21 22 24 25 2...

correct output
1 8 9 13 16 19 30 32 38 40 43 ...

user output
(empty)

Test 11

Group: 3

Verdict: ACCEPTED

input
100
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...

correct output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

user output
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

Test 12

Group: 3

Verdict:

input
100
3 4 5 5 6 6 7 7 7 8 8 8 9 9 9 ...

correct output
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

user output
(empty)

Test 13

Group: 3

Verdict:

input
100
502824619 505239810 505668108 ...

correct output
1 502824618 505239809 50566810...

user output
(empty)

Test 14

Group: 3

Verdict:

input
100
17871832 41618648 51611938 538...

correct output
3939271 13932561 37679377 4989...

user output
(empty)

Test 15

Group: 3

Verdict:

input
100
70588435 115481965 116040218 1...

correct output
5902586 64685849 109579379 110...

user output
(empty)