| Task: | Kemija |
| Sender: | henrikaalto |
| Submission time: | 2019-07-29 18:14:42 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | RUNTIME ERROR | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.01 s | details |
| #4 | RUNTIME ERROR | 0.01 s | details |
| #5 | ACCEPTED | 0.01 s | details |
| #6 | ACCEPTED | 0.01 s | details |
| #7 | RUNTIME ERROR | 0.01 s | details |
| #8 | ACCEPTED | 0.01 s | details |
| #9 | ACCEPTED | 0.01 s | details |
| #10 | RUNTIME ERROR | 0.01 s | details |
Compiler report
input/code.cpp: In function 'ii haku1(ii, ii)': input/code.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
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, ii y=-1)
{
fill(p, p + n, 0);
asd[0] = x;
p[0] = 1;
int it = 0;
while (!p[(it + 3) % n]) {
p[(it + 3) % n] = 1;
asd[(it + 3) % n] = asd[it] + dd[it];
it += 3;
it %= n;
}
if (y != -1) {
asd[1] = x;
p[1] = 1;
int it = 1;
while (!p[(it + 3) % n]) {
p[(it + 3) % n] = 1;
asd[(it + 3) % n] = asd[it] + dd[it];
it += 3;
it %= n;
}
}
for (int i = 0; i < n; ++i) if (!p[i]) {
asd[i] = v[i]-asd[(i-1+n)%n]-asd[(i+1)%n];
}
ii s = 0;
for (int i = 0; i < n; ++i) {
s += asd[i];
}
return s;
}
ii haku1(ii x, ii s)
{
ii y = 0;
for (ii z = 1l << 32; z; z /= 2)
{
if (v[0] - x - z > 0 && haku(x, y + z) <= s) y += z;
}
if (haku(x, y) <= s) return 1;
}
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;
d=vector<int>(n);
for (int i = 0; i < n; ++i) {
d[i] = v[(i+2)%n] - v[(i + 1) % n];
dd[i] = d[i];
}
if (n == 3) {
cout << 1 << " " << 1 << " " << s - 2 << "\n";
return 0;
}
if (n % 3 == 0) {
throw exception();
}
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: ACCEPTED
| input |
|---|
| 3
53 53 53 |
| correct output |
|---|
| 1
1 51 |
| user output |
|---|
| 1 1 51 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 5
8 9 12 9 ... |
| correct output |
|---|
| 1
5 3 4 2 |
| user output |
|---|
| 1 5 3 4 2 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 7
8 4 8 10 ... |
| correct output |
|---|
| 1
2 1 5 4 ... |
| user output |
|---|
| 1 2 1 5 4 ... |
Test 4
Verdict: RUNTIME ERROR
| input |
|---|
| 9
6 10 11 13 ... |
| correct output |
|---|
| 1
3 6 2 5 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::exception' what(): std::exception
Test 5
Verdict: ACCEPTED
| input |
|---|
| 11
14 15 15 12 ... |
| correct output |
|---|
| 2
9 4 2 6 ... |
| user output |
|---|
| 2 9 4 2 6 ... |
Test 6
Verdict: ACCEPTED
| input |
|---|
| 43
49 43 27 20 ... |
| correct output |
|---|
| 17
20 6 1 13 ... |
| user output |
|---|
| 17 20 6 1 13 ... Truncated |
Test 7
Verdict: RUNTIME ERROR
| input |
|---|
| 99
61 55 64 67 ... |
| correct output |
|---|
| 10
20 25 19 23 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::exception' what(): std::exception
Test 8
Verdict: ACCEPTED
| input |
|---|
| 500
34234 24097 6848 24240 ... |
| correct output |
|---|
| 18019
5147 931 770 22539 ... |
| user output |
|---|
| 18019 5147 931 770 22539 ... Truncated |
Test 9
Verdict: ACCEPTED
| input |
|---|
| 5002
257175927 192486676 334121373 435149455 ... |
| correct output |
|---|
| 146582420
29055198 16849058 288217117 130083280 ... |
| user output |
|---|
| 146582420 29055198 16849058 288217117 130083280 ... Truncated |
Test 10
Verdict: RUNTIME ERROR
| input |
|---|
| 9999
352949139 551279904 517124120 806539504 ... |
| correct output |
|---|
| 239036611
37116744 275126549 204880827 326532128 ... |
| user output |
|---|
| (empty) |
Error:
terminate called after throwing an instance of 'std::exception' what(): std::exception
