Task: | Jimi Hendrix |
Sender: | siirikuoppala |
Submission time: | 2016-08-04 15:45:26 +0300 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | WRONG ANSWER | 0.07 s | details |
#2 | WRONG ANSWER | 0.06 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | WRONG ANSWER | 0.06 s | details |
#5 | ACCEPTED | 0.06 s | details |
#6 | WRONG ANSWER | 0.06 s | details |
#7 | ACCEPTED | 0.06 s | details |
#8 | WRONG ANSWER | 0.06 s | details |
#9 | WRONG ANSWER | 0.05 s | details |
#10 | WRONG ANSWER | 0.05 s | details |
#11 | ACCEPTED | 0.06 s | details |
#12 | WRONG ANSWER | 0.06 s | details |
#13 | WRONG ANSWER | 0.06 s | details |
#14 | ACCEPTED | 0.06 s | details |
#15 | WRONG ANSWER | 0.06 s | details |
#16 | WRONG ANSWER | 0.05 s | details |
#17 | WRONG ANSWER | 0.05 s | details |
#18 | ACCEPTED | 0.05 s | details |
#19 | WRONG ANSWER | 0.06 s | details |
#20 | WRONG ANSWER | 0.06 s | details |
#21 | WRONG ANSWER | 0.06 s | details |
#22 | WRONG ANSWER | 0.06 s | details |
#23 | RUNTIME ERROR | 0.15 s | details |
#24 | RUNTIME ERROR | 0.15 s | details |
#25 | RUNTIME ERROR | 0.14 s | details |
#26 | RUNTIME ERROR | 0.15 s | details |
#27 | RUNTIME ERROR | 0.13 s | details |
#28 | RUNTIME ERROR | 0.15 s | details |
#29 | RUNTIME ERROR | 0.15 s | details |
#30 | RUNTIME ERROR | 0.15 s | details |
#31 | RUNTIME ERROR | 0.14 s | details |
#32 | RUNTIME ERROR | 0.16 s | details |
#33 | RUNTIME ERROR | 0.16 s | details |
#34 | RUNTIME ERROR | 0.14 s | details |
#35 | RUNTIME ERROR | 0.15 s | details |
#36 | RUNTIME ERROR | 0.14 s | details |
#37 | RUNTIME ERROR | 0.14 s | details |
#38 | RUNTIME ERROR | 0.14 s | details |
#39 | RUNTIME ERROR | 0.14 s | details |
#40 | RUNTIME ERROR | 0.13 s | details |
#41 | RUNTIME ERROR | 0.15 s | details |
#42 | RUNTIME ERROR | 0.13 s | details |
#43 | RUNTIME ERROR | 0.13 s | details |
#44 | RUNTIME ERROR | 0.13 s | details |
#45 | RUNTIME ERROR | 0.15 s | details |
#46 | RUNTIME ERROR | 0.14 s | details |
#47 | RUNTIME ERROR | 0.13 s | details |
#48 | RUNTIME ERROR | 0.13 s | details |
#49 | RUNTIME ERROR | 0.14 s | details |
#50 | RUNTIME ERROR | 0.15 s | details |
#51 | RUNTIME ERROR | 0.15 s | details |
#52 | RUNTIME ERROR | 0.15 s | details |
#53 | RUNTIME ERROR | 0.13 s | details |
#54 | RUNTIME ERROR | 0.15 s | details |
Code
#include <iostream> #include <vector> using namespace std; vector<int> v[101010], q; int x[101010], x2[101010], y[101010],y2[101010], z[101010], e[101010],e0[101010], e2[101010], e1[101010]; vector<char> w[101010]; int c[101010]; int main(){ int n, m; cin >> n >> m; for(int i=1; i<n; ++i){ int a, b; char ch; y[i]=m-1; y2[i]=m-1; cin >> a >> b >> ch; ++c[a]; ++c[b]; v[a].push_back(b); w[a].push_back(ch); v[b].push_back(a); w[b].push_back(ch); }y[n]=m-1; y2[n]=m-1; string sana; cin >> sana; for(int i=1; i<=n; ++i) { if(c[i]==1) { q.push_back(i); z[i]=1; } } int u=0; for(unsigned int i=0; i<q.size(); ++i){ int g=q[i]; z[g]=1; for(unsigned int j=0; j<v[g].size(); ++j){ u=v[g][j]; if(z[u]) continue; int h=x[g]; if(h<m && w[g][j]==sana[x[g]]) ++h; if(h>x[u]){ x2[u]=x[u]; e0[u]=e[u]; x[u]=h; e[u]=g; }else if(h>x2[g]){ x2[u]=h; e0[u]=g; } h=y[g]; if(h>=0 && w[g][j]==sana[y[g]]) --h; if(h<y[u]){ y2[u]=y[u]; e2[u]=e1[u]; y[u]=h; e1[u]=g; }else if(h<y2[u]){ y2[u]=h; e2[u]=g; } --c[u]; if(c[u]==1){ q.push_back(u); } } } /* for(int i=1; i<=n; ++i){ if(x[i]>y[i] && e[i]!=e1[i]){ int a=i, b=i; while(e[a]>0) a=e[a]; while(e1[b]>0) b=e1[b]; cout << a << " " << b; return 0; }else if(x[i]>y2[i]){ int a=i, b=e2[i]; while(e[a]>0) a=e[a]; while(e1[b]>0) b=e1[b]; if(b==0) b=i; cout << a << " " << b; return 0; }else if(x2[i]>y[i]){ int a=e0[i], b=i; while(e[a]>0) a=e[a]; while(e1[b]>0) b=e1[b]; if(a==0) a=i; cout << a << " " << b; return 0; } }*/ cout << "-1 -1"; }
Test details
Test 1
Verdict: WRONG ANSWER
input |
---|
9 3 1 2 a 2 3 b 2 4 a 4 5 b ... |
correct output |
---|
1 9 |
user output |
---|
-1 -1 |
Test 2
Verdict: WRONG ANSWER
input |
---|
2 1 1 2 b b |
correct output |
---|
2 1 |
user output |
---|
-1 -1 |
Test 3
Verdict: ACCEPTED
input |
---|
2 1 1 2 k p |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 4
Verdict: WRONG ANSWER
input |
---|
10 2 1 4 a 7 5 c 1 9 a 10 1 c ... |
correct output |
---|
2 1 |
user output |
---|
-1 -1 |
Test 5
Verdict: ACCEPTED
input |
---|
10 5 6 1 c 7 6 a 7 8 c 6 5 c ... |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 6
Verdict: WRONG ANSWER
input |
---|
10 3 3 10 c 1 9 b 4 8 a 10 4 b ... |
correct output |
---|
10 1 |
user output |
---|
-1 -1 |
Test 7
Verdict: ACCEPTED
input |
---|
10 5 9 1 c 5 4 c 1 7 a 3 9 c ... |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 8
Verdict: WRONG ANSWER
input |
---|
10 2 9 10 c 9 8 c 9 3 c 9 4 c ... |
correct output |
---|
1 10 |
user output |
---|
-1 -1 |
Test 9
Verdict: WRONG ANSWER
input |
---|
10 2 10 3 c 10 4 b 10 8 b 10 1 a ... |
correct output |
---|
1 9 |
user output |
---|
-1 -1 |
Test 10
Verdict: WRONG ANSWER
input |
---|
10 2 6 7 e 6 9 l 6 2 q 6 10 i ... |
correct output |
---|
1 9 |
user output |
---|
-1 -1 |
Test 11
Verdict: ACCEPTED
input |
---|
10 2 4 1 s 4 6 y 4 9 p 4 2 t ... |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 12
Verdict: WRONG ANSWER
input |
---|
1000 11 987 593 b 428 821 a 865 116 b 676 817 a ... |
correct output |
---|
998 1 |
user output |
---|
-1 -1 |
Test 13
Verdict: WRONG ANSWER
input |
---|
1000 10 782 148 a 498 256 a 389 269 a 156 291 b ... |
correct output |
---|
652 1 |
user output |
---|
-1 -1 |
Test 14
Verdict: ACCEPTED
input |
---|
1000 20 657 328 a 185 518 a 778 343 b 56 390 a ... |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 15
Verdict: WRONG ANSWER
input |
---|
1000 10 555 641 a 309 489 b 799 943 b 934 662 a ... |
correct output |
---|
953 332 |
user output |
---|
-1 -1 |
Test 16
Verdict: WRONG ANSWER
input |
---|
1000 6 161 816 b 25 712 b 540 233 b 980 204 c ... |
correct output |
---|
990 1 |
user output |
---|
-1 -1 |
Test 17
Verdict: WRONG ANSWER
input |
---|
1000 635 163 159 o 615 797 x 192 770 n 211 860 j ... |
correct output |
---|
650 951 |
user output |
---|
-1 -1 |
Test 18
Verdict: ACCEPTED
input |
---|
1000 191 370 983 e 792 207 u 260 334 t 504 718 t ... |
correct output |
---|
-1 -1 |
user output |
---|
-1 -1 |
Test 19
Verdict: WRONG ANSWER
input |
---|
1000 40 471 594 o 345 995 n 973 405 y 215 646 o ... |
correct output |
---|
1 982 |
user output |
---|
-1 -1 |
Test 20
Verdict: WRONG ANSWER
input |
---|
1000 100 151 902 a 730 935 b 295 369 b 823 145 a ... |
correct output |
---|
948 1 |
user output |
---|
-1 -1 |
Test 21
Verdict: WRONG ANSWER
input |
---|
1000 2 660 306 n 660 778 l 660 924 y 660 902 n ... |
correct output |
---|
988 969 |
user output |
---|
-1 -1 |
Test 22
Verdict: WRONG ANSWER
input |
---|
1000 2 526 579 a 526 150 b 526 168 a 526 24 b ... |
correct output |
---|
1000 1 |
user output |
---|
-1 -1 |
Test 23
Verdict: RUNTIME ERROR
input |
---|
200000 2 140844 190697 r 140844 124115 f 140844 112461 i 140844 19992 d ... |
correct output |
---|
124115 199952 |
user output |
---|
(empty) |
Test 24
Verdict: RUNTIME ERROR
input |
---|
200000 2 105421 5980 b 105421 150207 a 105421 115929 a 105421 77625 b ... |
correct output |
---|
200000 1 |
user output |
---|
(empty) |
Test 25
Verdict: RUNTIME ERROR
input |
---|
200000 50000 38207 51908 a 123390 86325 b 123134 78235 b 104677 7330 a ... |
correct output |
---|
112796 1 |
user output |
---|
(empty) |
Test 26
Verdict: RUNTIME ERROR
input |
---|
200000 150000 116487 13268 b 84833 43815 b 40993 188837 a 197098 131672 a ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 27
Verdict: RUNTIME ERROR
input |
---|
200000 5000 6663 37269 l 74938 58143 w 79955 85205 e 172041 175241 z ... |
correct output |
---|
199644 1 |
user output |
---|
(empty) |
Test 28
Verdict: RUNTIME ERROR
input |
---|
200000 10000 162365 187926 o 25849 45282 n 69475 76654 d 59397 127873 g ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 29
Verdict: RUNTIME ERROR
input |
---|
200000 4736 135910 152433 b 196857 44930 b 180142 58474 b 123198 131735 a ... |
correct output |
---|
193336 1 |
user output |
---|
(empty) |
Test 30
Verdict: RUNTIME ERROR
input |
---|
200000 54739 116541 156209 b 112813 171247 b 134494 179457 b 52303 59188 b ... |
correct output |
---|
175912 1 |
user output |
---|
(empty) |
Test 31
Verdict: RUNTIME ERROR
input |
---|
200000 49999 117084 195231 a 38504 191202 n 134618 132918 i 24748 150597 v ... |
correct output |
---|
198783 1 |
user output |
---|
(empty) |
Test 32
Verdict: RUNTIME ERROR
input |
---|
200000 20 56534 21846 a 127466 99775 b 197009 10481 a 13071 25861 a ... |
correct output |
---|
154647 179047 |
user output |
---|
(empty) |
Test 33
Verdict: RUNTIME ERROR
input |
---|
200000 18 25645 115335 b 138086 169629 b 147195 28130 a 90251 19229 b ... |
correct output |
---|
1 11192 |
user output |
---|
(empty) |
Test 34
Verdict: RUNTIME ERROR
input |
---|
200000 15 130040 52065 a 85066 121947 a 142587 138972 c 98852 109707 b ... |
correct output |
---|
186271 1 |
user output |
---|
(empty) |
Test 35
Verdict: RUNTIME ERROR
input |
---|
200000 13 186972 158038 n 141304 144334 c 150644 92260 d 75472 56494 e ... |
correct output |
---|
134673 188304 |
user output |
---|
(empty) |
Test 36
Verdict: RUNTIME ERROR
input |
---|
200000 22 77116 177355 b 41248 8511 a 196560 61055 b 93074 47152 b ... |
correct output |
---|
101231 1 |
user output |
---|
(empty) |
Test 37
Verdict: RUNTIME ERROR
input |
---|
200000 24 12092 977 b 89606 92554 a 98999 130713 b 29359 58778 a ... |
correct output |
---|
45421 191976 |
user output |
---|
(empty) |
Test 38
Verdict: RUNTIME ERROR
input |
---|
200000 32 42678 46956 a 85804 92343 a 58647 187834 a 40022 25789 a ... |
correct output |
---|
170898 83806 |
user output |
---|
(empty) |
Test 39
Verdict: RUNTIME ERROR
input |
---|
200000 37 97344 4860 b 59032 105557 b 33232 135880 a 41849 198146 b ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 40
Verdict: RUNTIME ERROR
input |
---|
200000 35 165160 188580 b 169019 179034 a 162600 167716 b 12953 68090 b ... |
correct output |
---|
34556 152796 |
user output |
---|
(empty) |
Test 41
Verdict: RUNTIME ERROR
input |
---|
200000 36 25981 130203 b 96700 180125 a 127368 165961 b 64857 173799 b ... |
correct output |
---|
140998 25928 |
user output |
---|
(empty) |
Test 42
Verdict: RUNTIME ERROR
input |
---|
200000 37 84272 141200 a 115974 60401 b 164159 9233 b 95061 109295 a ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 43
Verdict: RUNTIME ERROR
input |
---|
200000 9 64062 160380 r 125886 155571 c 171774 169538 y 98278 87688 l ... |
correct output |
---|
178549 166726 |
user output |
---|
(empty) |
Test 44
Verdict: RUNTIME ERROR
input |
---|
200000 10 180259 144845 g 116606 49642 c 17065 195194 h 19110 15737 w ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 45
Verdict: RUNTIME ERROR
input |
---|
200000 28 69795 159223 b 120740 49968 a 175591 112576 b 13475 97987 b ... |
correct output |
---|
191304 139389 |
user output |
---|
(empty) |
Test 46
Verdict: RUNTIME ERROR
input |
---|
200000 29 196920 93284 b 10733 37080 b 60158 81484 a 182923 50537 a ... |
correct output |
---|
118826 166004 |
user output |
---|
(empty) |
Test 47
Verdict: RUNTIME ERROR
input |
---|
200000 29 139335 36430 a 19077 167148 a 14826 196018 a 24497 91018 b ... |
correct output |
---|
176667 184941 |
user output |
---|
(empty) |
Test 48
Verdict: RUNTIME ERROR
input |
---|
200000 38 198494 65812 a 154023 48530 a 161230 125892 a 163972 48765 b ... |
correct output |
---|
-1 -1 |
user output |
---|
(empty) |
Test 49
Verdict: RUNTIME ERROR
input |
---|
200000 100000 138756 91790 c 50567 42961 d 199463 59094 d 158218 93083 e ... |
correct output |
---|
120276 158931 |
user output |
---|
(empty) |
Test 50
Verdict: RUNTIME ERROR
input |
---|
200000 100000 93749 174202 a 182960 2304 n 23460 111271 d 142390 124490 h ... |
correct output |
---|
197101 82602 |
user output |
---|
(empty) |
Test 51
Verdict: RUNTIME ERROR
input |
---|
200000 50000 26351 4065 d 190076 154406 b 47708 176166 c 56748 94747 d ... |
correct output |
---|
102345 166560 |
user output |
---|
(empty) |
Test 52
Verdict: RUNTIME ERROR
input |
---|
200000 50000 25937 89996 f 147254 157058 r 72097 126197 k 143403 116253 i ... |
correct output |
---|
175469 125703 |
user output |
---|
(empty) |
Test 53
Verdict: RUNTIME ERROR
input |
---|
200000 1000 138872 149623 e 161260 117770 a 151105 54329 a 120464 187446 d ... |
correct output |
---|
188942 1 |
user output |
---|
(empty) |
Test 54
Verdict: RUNTIME ERROR
input |
---|
200000 1000 53986 146114 r 139076 142403 c 86688 88562 g 40058 165888 g ... |
correct output |
---|
140202 1 |
user output |
---|
(empty) |