CSES - COCI 2007/2008 #2 - Results
Submission details
Task:Turbo
Sender:henrikaalto
Submission time:2019-07-29 17:01:07 +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.02 sdetails
#90.03 sdetails
#100.04 sdetails

Code

#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
using ii=long long;

vector<int> v,d;

int p[10100];
ii asd[10100];
ii dd[10100];
int n;

ii haku(ii x)
{
    fill(p, p + n, 0);
    asd[0] = x;
    p[0] = 1;
    int it = 0;
    if (n & 1) {
        while (!p[(it + 2) % n]) {
            p[(it + 2) % n] = 1;
            asd[(it + 2) % n] = asd[it] + dd[it];
            it += 2;
            it %= n;
        }
    }
    else {
        while (!p[(it + 1) % n]) {
            p[(it + 1) % n] = 1;
            asd[(it + 1) % n] = asd[it] + dd[it];
            ++it;
        }
    }
    ii s = 0;
    for (int i = 0; i < n; ++i) {
        s += asd[i];
    }
    return s;
}


int main()
{
    cin >> n;
    v=vector<int>(n);
    ii s = 0;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        s += v[i];
    }
    assert(s % 3 == 0);
    s /= 3;
    if (n == 3) {
        cout << 1 << " " << 1 << " " << s - 2 << "\n";
        return 0;
    }
    d=vector<int>(n);
    for (int i = 0; i < n; ++i) {
        d[i] = v[i] - v[(i + 1) % n];
        dd[(i + 2) % n] = d[i];
        //printf("dd[%d] =%d\n", (i+2)%n, d[i]);
    }
    ii b = 0;
    for (ii z = (1l << 32); z; z /= 2) {
        if (haku(b + z) <= s) b += z;
    }
    haku(b);
    for (int i = 0; i < n; ++i) {
        cout << asd[i] << "\n";
    }
}

Test details

Test 1

Verdict:

input
5
4
3
2
1
...

correct output
3
0
2
1
0

user output
3
1
-1
2
0

Test 2

Verdict:

input
8
2
3
5
8
...

correct output
6
3
0
2
0
...

user output
5
0
4
3
1
...

Test 3

Verdict:

input
10
6
2
4
1
...

correct output
3
3
1
3
2
...

user output
(empty)

Error:
code: input/code.cpp:51: int main(): Assertion `s % 3 == 0' failed.

Test 4

Verdict:

input
17
9
8
15
14
...

correct output
15
10
13
2
12
...

user output
13
1
11
-5
12
...

Test 5

Verdict:

input
33
19
11
16
33
...

correct output
30
28
12
25
3
...

user output
33
-15
22
-14
30
...
Truncated

Test 6

Verdict:

input
72
72
67
13
28
...

correct output
51
70
43
21
54
...

user output
0
49
-17
-12
42
...
Truncated

Test 7

Verdict:

input
95
52
58
78
80
...

correct output
49
58
81
80
76
...

user output
0
231
-66
258
-72
...
Truncated

Test 8

Verdict:

input
21224
21139
2725
3303
13148
...

correct output
13305
9764
18691
1254
7043
...

user output
9475
661
-10513
7901
7323
...
Truncated

Test 9

Verdict:

input
61370
35656
9205
5841
17303
...

correct output
56587
43741
48553
16182
4458
...

user output
(empty)

Test 10

Verdict:

input
100000
80825
41163
35758
92141
...

correct output
8989
79515
58926
79542
62384
...

user output
(empty)

Error:
code: input/code.cpp:51: int main(): Assertion `s % 3 == 0' failed.