Task: | Mobiles |
Sender: | Lieska |
Submission time: | 2019-03-07 18:14:57 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.02 s | details |
#2 | ACCEPTED | 0.01 s | details |
#3 | ACCEPTED | 0.01 s | details |
#4 | ACCEPTED | 0.02 s | details |
#5 | ACCEPTED | 0.01 s | details |
#6 | ACCEPTED | 0.01 s | details |
#7 | ACCEPTED | 0.02 s | details |
#8 | ACCEPTED | 0.02 s | details |
#9 | WRONG ANSWER | 0.02 s | details |
#10 | WRONG ANSWER | 0.01 s | details |
#11 | WRONG ANSWER | 0.02 s | details |
#12 | WRONG ANSWER | 0.02 s | details |
#13 | ACCEPTED | 0.01 s | details |
#14 | ACCEPTED | 0.01 s | details |
#15 | ACCEPTED | 0.02 s | details |
#16 | ACCEPTED | 0.03 s | details |
#17 | ACCEPTED | 0.02 s | details |
#18 | ACCEPTED | 0.03 s | details |
#19 | ACCEPTED | 0.02 s | details |
#20 | ACCEPTED | 0.02 s | details |
#21 | ACCEPTED | 0.02 s | details |
#22 | WRONG ANSWER | 0.01 s | details |
#23 | WRONG ANSWER | 0.02 s | details |
#24 | WRONG ANSWER | 0.03 s | details |
#25 | WRONG ANSWER | 0.08 s | details |
#26 | ACCEPTED | 0.02 s | details |
#27 | ACCEPTED | 0.02 s | details |
#28 | WRONG ANSWER | 0.02 s | details |
#29 | WRONG ANSWER | 0.03 s | details |
#30 | ACCEPTED | 0.02 s | details |
#31 | ACCEPTED | 0.02 s | details |
#32 | ACCEPTED | 0.04 s | details |
#33 | ACCEPTED | 0.08 s | details |
#34 | WRONG ANSWER | 0.07 s | details |
#35 | ACCEPTED | 0.08 s | details |
#36 | ACCEPTED | 0.08 s | details |
#37 | WRONG ANSWER | 0.09 s | details |
#38 | ACCEPTED | 0.08 s | details |
#39 | ACCEPTED | 0.08 s | details |
#40 | ACCEPTED | 0.08 s | details |
#41 | ACCEPTED | 0.08 s | details |
#42 | ACCEPTED | 0.08 s | details |
Code
#include <iostream> using namespace std; int t[100001][2]; int k, l, n, x, c, d, e, y; void f(int a, int b){ if (a==-1 && e==0) { if (b!=c && b!=d){ if (c==0) c=b; else if (d==0 && (b==c+1 || b==c-1)) d=b; else e=1; } } else if (e==0) { f(t[a][0], b+1); f(t[a][1], b+1); } } int g(int a){ if (a==-1) return 1; int v=g(t[a][0]); int w=g(t[a][1]); if (v<w) y++; return v+w; } int main(){ cin >> n; for (int i=1; i<=n; ++i) { cin >> k >> l; t[i][0]=k; t[i][1]=l; if ((k==-1 && l>0) || (k>0 && l==-1) ) x++; } if (x>1) cout << "-1\n"; else f(1, 1); if (e) cout << "-1\n"; else { g(1); cout << y << "\n"; } }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 -1 -1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 2
Verdict: ACCEPTED
input |
---|
2 2 -1 -1 -1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 3
Verdict: ACCEPTED
input |
---|
2 -1 2 -1 -1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 4
Verdict: ACCEPTED
input |
---|
4 2 3 4 -1 -1 -1 -1 -1 |
correct output |
---|
0 |
user output |
---|
0 |
Test 5
Verdict: ACCEPTED
input |
---|
4 2 3 -1 4 -1 -1 -1 -1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 6
Verdict: ACCEPTED
input |
---|
4 2 3 -1 -1 4 -1 -1 -1 |
correct output |
---|
1 |
user output |
---|
1 |
Test 7
Verdict: ACCEPTED
input |
---|
4 2 3 -1 -1 -1 4 -1 -1 |
correct output |
---|
2 |
user output |
---|
2 |
Test 8
Verdict: ACCEPTED
input |
---|
5 2 3 4 5 -1 -1 -1 -1 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 9
Verdict: WRONG ANSWER
input |
---|
5 2 3 4 -1 5 -1 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 0 |
Test 10
Verdict: WRONG ANSWER
input |
---|
5 2 3 4 -1 -1 5 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 1 |
Test 11
Verdict: WRONG ANSWER
input |
---|
5 2 3 -1 4 5 -1 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 1 |
Test 12
Verdict: WRONG ANSWER
input |
---|
5 2 3 -1 4 -1 5 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 2 |
Test 13
Verdict: ACCEPTED
input |
---|
5 2 3 -1 -1 4 5 -1 -1 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 14
Verdict: ACCEPTED
input |
---|
6 2 3 4 5 6 -1 -1 -1 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 15
Verdict: ACCEPTED
input |
---|
6 2 3 4 5 -1 6 -1 -1 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 16
Verdict: ACCEPTED
input |
---|
6 2 3 4 -1 5 6 -1 -1 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 17
Verdict: ACCEPTED
input |
---|
6 2 3 -1 4 5 6 -1 -1 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 18
Verdict: ACCEPTED
input |
---|
19 2 3 6 5 4 7 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 19
Verdict: ACCEPTED
input |
---|
9 3 2 4 5 -1 -1 6 9 ... |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 20
Verdict: ACCEPTED
input |
---|
4 -1 2 3 4 -1 -1 -1 -1 |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 21
Verdict: ACCEPTED
input |
---|
12 3 2 4 5 -1 6 7 9 ... |
correct output |
---|
-1 |
user output |
---|
-1 |
Test 22
Verdict: WRONG ANSWER
input |
---|
10 3 2 7 5 4 6 8 10 ... |
correct output |
---|
-1 |
user output |
---|
0 |
Test 23
Verdict: WRONG ANSWER
input |
---|
1000 2 -1 -1 3 4 -1 5 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 507 |
Test 24
Verdict: WRONG ANSWER
input |
---|
10000 2 -1 -1 3 4 -1 5 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 5086 |
Test 25
Verdict: WRONG ANSWER
input |
---|
100000 2 -1 -1 3 4 -1 5 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 50244 |
Test 26
Verdict: ACCEPTED
input |
---|
10 2 3 6 5 7 4 -1 -1 ... |
correct output |
---|
2 |
user output |
---|
2 |
Test 27
Verdict: ACCEPTED
input |
---|
18 2 3 7 6 5 4 11 9 ... |
correct output |
---|
3 |
user output |
---|
3 |
Test 28
Verdict: WRONG ANSWER
input |
---|
13 3 2 4 5 7 6 -1 -1 ... |
correct output |
---|
-1 |
user output |
---|
-1 4 |
Test 29
Verdict: WRONG ANSWER
input |
---|
660 3 2 5 6 7 4 10 8 ... |
correct output |
---|
-1 |
user output |
---|
-1 89 |
Test 30
Verdict: ACCEPTED
input |
---|
1250 2 3 6 7 5 4 10 14 ... |
correct output |
---|
7 |
user output |
---|
7 |
Test 31
Verdict: ACCEPTED
input |
---|
5000 2 3 6 7 5 4 11 14 ... |
correct output |
---|
4 |
user output |
---|
4 |
Test 32
Verdict: ACCEPTED
input |
---|
32767 2 3 5 4 7 6 13 14 ... |
correct output |
---|
0 |
user output |
---|
0 |
Test 33
Verdict: ACCEPTED
input |
---|
100000 2 3 5 7 4 6 15 14 ... |
correct output |
---|
7 |
user output |
---|
7 |
Test 34
Verdict: WRONG ANSWER
input |
---|
98348 3 2 7 5 6 4 10 8 ... |
correct output |
---|
-1 |
user output |
---|
-1 19722 |
Test 35
Verdict: ACCEPTED
input |
---|
100000 2 3 5 7 4 6 15 14 ... |
correct output |
---|
7 |
user output |
---|
7 |
Test 36
Verdict: ACCEPTED
input |
---|
99999 3 2 7 5 6 4 10 8 ... |
correct output |
---|
5 |
user output |
---|
5 |
Test 37
Verdict: WRONG ANSWER
input |
---|
98348 3 2 7 5 6 4 10 8 ... |
correct output |
---|
-1 |
user output |
---|
-1 19722 |
Test 38
Verdict: ACCEPTED
input |
---|
98303 3 2 5 4 7 6 9 8 ... |
correct output |
---|
1 |
user output |
---|
1 |
Test 39
Verdict: ACCEPTED
input |
---|
98304 3 2 5 4 7 6 9 8 ... |
correct output |
---|
16 |
user output |
---|
16 |
Test 40
Verdict: ACCEPTED
input |
---|
99989 3 2 5 4 7 6 9 8 ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 41
Verdict: ACCEPTED
input |
---|
99989 2 3 4 5 6 7 8 9 ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 42
Verdict: ACCEPTED
input |
---|
100000 3 2 5 4 7 6 9 8 ... |
correct output |
---|
16 |
user output |
---|
16 |