CSES - Putka Open 2020 – 2/5 - Results
Submission details
Task:Summat
Sender:tykkipeli
Submission time:2020-09-26 02:56:09 +0300
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED32
#3ACCEPTED56
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
#7ACCEPTED0.01 s2, 3details
#8ACCEPTED0.01 s2, 3details
#9ACCEPTED0.01 s2, 3details
#10ACCEPTED0.01 s2, 3details
#11ACCEPTED0.01 s3details
#12ACCEPTED0.01 s3details
#13ACCEPTED0.10 s3details
#14ACCEPTED0.01 s3details
#15ACCEPTED0.02 s3details

Code

#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;

int b[10101];
int ans[1010];
map<int,int> m;

bool check(int ind, int n) {
    int N = n*(n-1)/2;
    ans[2] = (b[ind] + b[1] - b[0])/2;
    ans[0] = b[1] - ans[2];
    ans[1] = ans[2] - (b[1] - b[0]);
    if (ans[0] < 1 || ans[1] < 1 || ans[2] < 1) return false;
    for (int i = 3; i <= ind; i++) {
        ans[i] = b[i-1]-ans[0];
    }
    m.clear();
    for (int i = 0; i <= ind; i++) {
        for (int j = i+1; j <= ind; j++) {
            m[ans[i]+ans[j]]++;
        }
    }
    for (int i = 0; i <= ind; i++) m[b[i]]--;
    int mones = ind+1;
    for (int i = ind+1; i < N; i++) {
        if (m[b[i]] > 0) {
            m[b[i]]--;
        } else {
            if (mones == n) return false;
            ans[mones] = b[i]-ans[0];
            if (ans[mones] < 1) return false;
            for (int j = 1; j < mones; j++) m[ans[j]+ans[mones]]++;
            mones++;
        }
    }
    return true;
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin >> n;
    int N = n*(n-1)/2;
    for (int i = 0; i < N; i++) cin >> b[i];
    sort(b,b+N);
    for (int i = 2; i < 101; i++) {
        if (check(i,n)) break;
    }
    for (int i = 0; i < n; i++) cout << ans[i] << " ";
    cout << "\n";
}

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: ACCEPTED

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
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Test 8

Group: 2, 3

Verdict: ACCEPTED

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
1 51 54 54 56 61 61 62 63 65 7...

Test 9

Group: 2, 3

Verdict: ACCEPTED

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
8 17 22 23 24 28 43 50 53 55 6...

Test 10

Group: 2, 3

Verdict: ACCEPTED

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
1 8 9 13 16 19 30 32 38 40 43 ...

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: ACCEPTED

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
1 2 3 4 5 6 7 8 9 10 11 12 13 ...

Test 13

Group: 3

Verdict: ACCEPTED

input
100
502824619 505239810 505668108 ...

correct output
1 502824618 505239809 50566810...

user output
1 502824618 505239809 50566810...

Test 14

Group: 3

Verdict: ACCEPTED

input
100
17871832 41618648 51611938 538...

correct output
3939271 13932561 37679377 4989...

user output
3939271 13932561 37679377 4989...

Test 15

Group: 3

Verdict: ACCEPTED

input
100
70588435 115481965 116040218 1...

correct output
5902586 64685849 109579379 110...

user output
5902586 64685849 109579379 110...