CSES - COCI 2007/2008 #2 - Results
Submission details
Task:Kemija
Sender:henrikaalto
Submission time:2019-07-29 18:59:34 +0300
Language:C++ (C++17)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails
#70.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ii=long long;
int main()
{
    int n;
    cin >> n;
    vector<int>v(n),d(n),dd(n);
    ii s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        s += v[i];
    }
    s /= 3;
    for (int i = 0; i < n; ++i) {
        d[i] = v[(i+2)%n] - v[(i + 1) % n];
        dd[i] = d[i];
    }
    if (n % 3) {
        // n * x + z = s
        // s - z = x * n  || : n
        // (s - z) / n = x
        vector<int> vis(n);
        vis[0] = 1;
        int z = 0;
        for (int i = 3; ; (i += 3) %= n) {
            if (vis[(i+3)%n]) break;
            z += dd[i];
        }
        vector<int> res(n);
        res[0] = (s - z) / n;
        for (int i = 0; ; (i+=3)%=n) {
            if (!res[(i+3)%n]) res[(i+3)%n] = res[i] + dd[i];
            else break;
        }
        for (int i = 0; i<  n; ++i) {
            cout << res[i] << "\n";
        }
    }
}

Test details

Test 1

Verdict:

input
3
53
53
53

correct output
1
1
51

user output
(empty)

Test 2

Verdict:

input
5
8
9
12
9
...

correct output
1
5
3
4
2

user output
3
7
5
6
4

Test 3

Verdict:

input
7
8
4
8
10
...

correct output
1
2
1
5
4
...

user output
3
4
3
7
6
...

Test 4

Verdict:

input
9
6
10
11
13
...

correct output
1
3
6
2
5
...

user output
(empty)

Test 5

Verdict:

input
11
14
15
15
12
...

correct output
2
9
4
2
6
...

user output
5
12
7
5
9
...

Test 6

Verdict:

input
43
49
43
27
20
...

correct output
17
20
6
1
13
...

user output
10
13
-1
-6
6
...
Truncated

Test 7

Verdict:

input
99
61
55
64
67
...

correct output
10
20
25
19
23
...

user output
(empty)

Test 8

Verdict:

input
500
34234
24097
6848
24240
...

correct output
18019
5147
931
770
22539
...

user output
15569
2697
-1519
-1680
20089
...
Truncated

Test 9

Verdict:

input
5002
257175927
192486676
334121373
435149455
...

correct output
146582420
29055198
16849058
288217117
130083280
...

user output
159107743
41580521
29374381
300742440
142608603
...
Truncated

Test 10

Verdict:

input
9999
352949139
551279904
517124120
806539504
...

correct output
239036611
37116744
275126549
204880827
326532128
...

user output
(empty)