Task: | HDRF |
Sender: | On |
Submission time: | 2017-03-09 15:00:47 +0200 |
Language: | C++ |
Status: | READY |
Result: | 0 |
group | verdict | score |
---|---|---|
#1 | WRONG ANSWER | 0 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.03 s | details |
#2 | WRONG ANSWER | 0.03 s | details |
#3 | WRONG ANSWER | 0.04 s | details |
#4 | WRONG ANSWER | 0.04 s | details |
#5 | WRONG ANSWER | 0.05 s | details |
#6 | WRONG ANSWER | 0.04 s | details |
#7 | WRONG ANSWER | 0.05 s | details |
#8 | WRONG ANSWER | 0.04 s | details |
#9 | ACCEPTED | 0.03 s | details |
#10 | WRONG ANSWER | 0.03 s | details |
#11 | WRONG ANSWER | 0.04 s | details |
#12 | WRONG ANSWER | 0.04 s | details |
#13 | WRONG ANSWER | 0.04 s | details |
#14 | WRONG ANSWER | 0.04 s | details |
#15 | WRONG ANSWER | 0.05 s | details |
#16 | WRONG ANSWER | 0.04 s | details |
#17 | WRONG ANSWER | 0.04 s | details |
#18 | WRONG ANSWER | 0.04 s | details |
#19 | WRONG ANSWER | 0.03 s | details |
#20 | WRONG ANSWER | 0.04 s | details |
#21 | WRONG ANSWER | 0.03 s | details |
#22 | WRONG ANSWER | 0.03 s | details |
#23 | WRONG ANSWER | 0.03 s | details |
#24 | WRONG ANSWER | 0.03 s | details |
#25 | WRONG ANSWER | 0.04 s | details |
#26 | WRONG ANSWER | 0.04 s | details |
#27 | WRONG ANSWER | 0.03 s | details |
#28 | WRONG ANSWER | 0.04 s | details |
#29 | WRONG ANSWER | 0.04 s | details |
#30 | WRONG ANSWER | 0.03 s | details |
#31 | WRONG ANSWER | 0.04 s | details |
#32 | WRONG ANSWER | 0.05 s | details |
#33 | WRONG ANSWER | 0.04 s | details |
#34 | WRONG ANSWER | 0.03 s | details |
#35 | WRONG ANSWER | 0.03 s | details |
#36 | WRONG ANSWER | 0.03 s | details |
#37 | WRONG ANSWER | 0.04 s | details |
#38 | WRONG ANSWER | 0.03 s | details |
#39 | WRONG ANSWER | 0.04 s | details |
#40 | WRONG ANSWER | 0.05 s | details |
#41 | WRONG ANSWER | 0.05 s | details |
#42 | WRONG ANSWER | 0.03 s | details |
#43 | WRONG ANSWER | 0.04 s | details |
#44 | WRONG ANSWER | 0.05 s | details |
#45 | WRONG ANSWER | 0.04 s | details |
#46 | WRONG ANSWER | 0.03 s | details |
#47 | WRONG ANSWER | 0.04 s | details |
#48 | WRONG ANSWER | 0.03 s | details |
#49 | WRONG ANSWER | 0.04 s | details |
#50 | WRONG ANSWER | 0.04 s | details |
#51 | WRONG ANSWER | 0.04 s | details |
#52 | WRONG ANSWER | 0.04 s | details |
#53 | WRONG ANSWER | 0.13 s | details |
#54 | WRONG ANSWER | 0.11 s | details |
#55 | WRONG ANSWER | 0.11 s | details |
#56 | WRONG ANSWER | 0.10 s | details |
#57 | WRONG ANSWER | 0.10 s | details |
#58 | ACCEPTED | 0.13 s | details |
#59 | WRONG ANSWER | 0.10 s | details |
#60 | WRONG ANSWER | 0.11 s | details |
#61 | WRONG ANSWER | 0.11 s | details |
#62 | WRONG ANSWER | 0.07 s | details |
#63 | ACCEPTED | 0.09 s | details |
Code
#include <bits/stdc++.h> using namespace std; int n, t; vector<vector<int>> v; vector<int> w, r, p, d; vector<bool> z; void f(int x) { if(z[x]) return; r[x] = x; for(auto i : v[x]) f(i); for(auto i : v[x]) { if(z[i]) continue; if(w[r[i]] < w[x]) r[x] = r[i]; return; } } void g(int x) { int y = p[x]; while(r[p[y]] == x && y != 0) y = p[y]; f(y >= 0 ? y : 0); } void h(int x) { if(z[x]) return; z[x] = true; if(v[x].size() > 0) for(auto i : v[x]) h(i); g(x); d.push_back(x); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; p.resize(n); r.resize(n); v.resize(n); w.resize(n); z.resize(n); p[0] = -1; for(int i = 0; i < n-1; i++) { cin >> t; v[t-1].push_back(i+1); p[i+1] = t-1; } for(int i = 0; i < n; i++) cin >> w[i]; for(int i = 0; i < n; i++) { sort(v[i].begin(), v[i].end(), [](int a, int b) { if(w[a] == w[b]) return b > a; else return w[b] > w[a]; }); } f(0); for(int i = 0; i < n; i++) { sort(v[i].begin(), v[i].end(), [](int a, int b) { if(w[r[a]] == w[r[b]]) return b > a; else return w[r[b]] > w[r[a]]; }); } h(0); for(auto i : d) cout << (i+1) << " "; cout << endl; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
2 1 1 2 |
correct output |
---|
2 1 |
user output |
---|
2 1 |
Test 2
Verdict: WRONG ANSWER
input |
---|
100 85 42 34 7 48 48 63 90 37 80 2... |
correct output |
---|
95 2 85 65 59 8 36 24 82 71 61... |
user output |
---|
88 81 93 58 70 13 50 76 10 45 ... |
Test 3
Verdict: WRONG ANSWER
input |
---|
100 14 35 99 80 25 28 11 70 24 51 ... |
correct output |
---|
72 77 43 9 93 49 70 13 69 66 7... |
user output |
---|
77 42 92 55 67 53 94 8 46 89 1... |
Test 4
Verdict: WRONG ANSWER
input |
---|
100 60 55 18 87 58 26 35 17 48 9 8... |
correct output |
---|
89 77 39 93 49 64 56 38 74 80 ... |
user output |
---|
39 85 73 89 6 58 88 68 25 29 8... |
Test 5
Verdict: WRONG ANSWER
input |
---|
100 57 68 23 81 85 54 62 73 100 10... |
correct output |
---|
10 11 100 40 58 86 67 28 26 51... |
user output |
---|
40 51 52 69 4 23 59 64 48 46 1... |
Test 6
Verdict: WRONG ANSWER
input |
---|
100 33 22 18 33 26 31 57 23 93 97 ... |
correct output |
---|
60 100 4 10 76 50 71 94 17 20 ... |
user output |
---|
10 12 82 35 76 50 24 56 88 92 ... |
Test 7
Verdict: WRONG ANSWER
input |
---|
200 87 30 52 56 164 149 193 82 188... |
correct output |
---|
191 178 85 36 55 35 43 3 30 97... |
user output |
---|
80 57 65 107 28 171 24 83 138 ... |
Test 8
Verdict: WRONG ANSWER
input |
---|
200 3 59 148 66 188 81 172 152 170... |
correct output |
---|
115 121 107 74 151 91 80 118 2... |
user output |
---|
115 85 49 174 84 80 118 96 110... |
Test 9
Verdict: ACCEPTED
input |
---|
5 4 4 1 1 3 5 2 1 4 |
correct output |
---|
3 2 4 5 1 |
user output |
---|
3 2 4 5 1 |
Test 10
Verdict: WRONG ANSWER
input |
---|
200 158 82 152 26 46 191 100 180 2... |
correct output |
---|
13 181 18 163 24 130 2 158 184... |
user output |
---|
179 194 33 55 136 71 72 16 14 ... |
Test 11
Verdict: WRONG ANSWER
input |
---|
200 197 134 27 109 102 77 30 71 14... |
correct output |
---|
112 144 12 131 64 137 175 117 ... |
user output |
---|
112 144 12 64 131 137 175 117 ... |
Test 12
Verdict: WRONG ANSWER
input |
---|
200 101 78 128 55 9 78 35 87 56 6 ... |
correct output |
---|
197 138 177 126 68 147 145 73 ... |
user output |
---|
31 102 108 116 135 106 137 67 ... |
Test 13
Verdict: WRONG ANSWER
input |
---|
300 259 151 284 164 193 153 20 153... |
correct output |
---|
63 240 115 257 206 66 42 113 2... |
user output |
---|
152 78 37 220 35 34 257 206 66... |
Test 14
Verdict: WRONG ANSWER
input |
---|
300 127 280 20 1 186 215 59 101 25... |
correct output |
---|
10 257 179 56 174 135 42 169 2... |
user output |
---|
232 179 56 135 174 42 169 261 ... |
Test 15
Verdict: WRONG ANSWER
input |
---|
300 81 283 149 69 227 39 144 70 28... |
correct output |
---|
207 54 241 126 151 138 118 51 ... |
user output |
---|
61 100 109 9 70 289 103 268 43... |
Test 16
Verdict: WRONG ANSWER
input |
---|
300 12 265 12 226 196 226 179 185 ... |
correct output |
---|
220 198 242 11 256 125 212 174... |
user output |
---|
133 40 251 45 47 197 276 243 1... |
Test 17
Verdict: WRONG ANSWER
input |
---|
300 91 60 106 191 300 27 191 10 28... |
correct output |
---|
247 142 103 178 256 9 154 16 8... |
user output |
---|
78 238 47 170 147 103 178 256 ... |
Test 18
Verdict: WRONG ANSWER
input |
---|
400 331 329 307 121 72 279 344 213... |
correct output |
---|
346 367 343 332 11 100 44 77 1... |
user output |
---|
367 346 206 80 195 69 200 14 3... |
Test 19
Verdict: WRONG ANSWER
input |
---|
400 305 158 217 151 291 189 338 26... |
correct output |
---|
114 319 34 163 183 13 175 87 3... |
user output |
---|
288 298 180 43 304 195 238 400... |
Test 20
Verdict: WRONG ANSWER
input |
---|
400 354 21 151 275 188 159 154 328... |
correct output |
---|
232 184 314 111 112 227 393 5 ... |
user output |
---|
264 317 226 322 117 127 153 28... |
Test 21
Verdict: WRONG ANSWER
input |
---|
400 279 376 349 253 29 112 157 110... |
correct output |
---|
131 226 382 240 276 66 136 190... |
user output |
---|
152 131 226 382 240 210 332 26... |
Test 22
Verdict: WRONG ANSWER
input |
---|
400 370 349 95 374 373 220 187 223... |
correct output |
---|
269 29 129 266 222 394 395 275... |
user output |
---|
269 88 101 277 293 177 353 193... |
Test 23
Verdict: WRONG ANSWER
input |
---|
500 55 153 455 345 272 93 24 440 4... |
correct output |
---|
69 104 10 499 433 251 337 470 ... |
user output |
---|
46 400 369 145 239 407 187 500... |
Test 24
Verdict: WRONG ANSWER
input |
---|
500 297 2 308 68 421 288 151 117 3... |
correct output |
---|
494 444 419 370 107 261 439 16... |
user output |
---|
441 313 140 120 264 3 404 187 ... |
Test 25
Verdict: WRONG ANSWER
input |
---|
500 448 452 207 81 168 458 431 499... |
correct output |
---|
445 117 188 206 156 438 321 13... |
user output |
---|
297 336 161 289 356 132 341 39... |
Test 26
Verdict: WRONG ANSWER
input |
---|
500 462 261 399 462 328 277 22 319... |
correct output |
---|
73 258 171 245 148 181 110 297... |
user output |
---|
185 380 442 20 66 89 453 335 2... |
Test 27
Verdict: WRONG ANSWER
input |
---|
500 344 249 220 264 277 322 90 164... |
correct output |
---|
36 419 257 318 414 355 179 107... |
user output |
---|
349 125 419 452 396 292 255 34... |
Test 28
Verdict: WRONG ANSWER
input |
---|
600 518 98 32 91 331 69 562 488 31... |
correct output |
---|
438 286 235 368 340 354 338 39... |
user output |
---|
334 219 341 396 108 560 250 83... |
Test 29
Verdict: WRONG ANSWER
input |
---|
600 107 462 245 156 410 126 414 28... |
correct output |
---|
116 194 344 560 59 337 543 233... |
user output |
---|
263 82 286 63 390 501 362 386 ... |
Test 30
Verdict: WRONG ANSWER
input |
---|
600 158 283 486 462 491 341 528 83... |
correct output |
---|
581 301 19 557 374 433 396 278... |
user output |
---|
458 516 194 289 156 161 33 71 ... |
Test 31
Verdict: WRONG ANSWER
input |
---|
600 222 353 470 77 426 573 201 36 ... |
correct output |
---|
346 194 423 385 43 161 373 154... |
user output |
---|
464 408 132 339 130 215 298 18... |
Test 32
Verdict: WRONG ANSWER
input |
---|
600 563 593 20 438 30 525 291 199 ... |
correct output |
---|
275 171 292 426 133 136 285 21... |
user output |
---|
433 577 411 562 360 61 476 4 1... |
Test 33
Verdict: WRONG ANSWER
input |
---|
700 578 320 44 92 179 368 524 61 5... |
correct output |
---|
127 21 504 411 619 214 103 230... |
user output |
---|
23 64 523 146 489 352 221 690 ... |
Test 34
Verdict: WRONG ANSWER
input |
---|
700 172 367 171 680 68 431 90 465 ... |
correct output |
---|
336 263 10 104 370 572 544 173... |
user output |
---|
336 263 10 637 379 587 676 370... |
Test 35
Verdict: WRONG ANSWER
input |
---|
700 592 485 633 263 13 500 234 164... |
correct output |
---|
580 329 635 17 574 191 672 280... |
user output |
---|
603 406 588 27 210 601 172 465... |
Test 36
Verdict: WRONG ANSWER
input |
---|
700 281 479 279 98 11 309 125 538 ... |
correct output |
---|
509 340 171 226 298 317 16 200... |
user output |
---|
690 618 509 340 171 226 595 38... |
Test 37
Verdict: WRONG ANSWER
input |
---|
700 129 142 226 50 471 445 533 580... |
correct output |
---|
69 96 324 645 208 167 652 431 ... |
user output |
---|
268 638 557 595 698 457 227 28... |
Test 38
Verdict: WRONG ANSWER
input |
---|
800 299 797 180 295 481 278 317 59... |
correct output |
---|
149 251 709 708 421 733 798 24... |
user output |
---|
149 752 545 702 674 329 653 53... |
Test 39
Verdict: WRONG ANSWER
input |
---|
800 61 61 439 356 175 216 137 325 ... |
correct output |
---|
792 30 44 426 502 39 390 264 3... |
user output |
---|
44 548 89 586 182 366 783 204 ... |
Test 40
Verdict: WRONG ANSWER
input |
---|
800 310 772 726 621 51 556 795 711... |
correct output |
---|
318 161 733 86 72 271 483 670 ... |
user output |
---|
709 628 365 139 155 760 368 14... |
Test 41
Verdict: WRONG ANSWER
input |
---|
800 24 46 39 770 278 218 657 362 7... |
correct output |
---|
566 303 132 186 47 504 78 356 ... |
user output |
---|
66 78 151 614 672 591 288 361 ... |
Test 42
Verdict: WRONG ANSWER
input |
---|
800 166 688 171 741 50 312 299 562... |
correct output |
---|
119 186 291 331 48 603 575 162... |
user output |
---|
449 725 338 581 248 319 455 36... |
Test 43
Verdict: WRONG ANSWER
input |
---|
900 793 286 814 824 112 575 524 54... |
correct output |
---|
40 835 125 199 491 175 355 624... |
user output |
---|
709 414 307 386 217 144 541 19... |
Test 44
Verdict: WRONG ANSWER
input |
---|
900 86 520 750 436 711 598 268 322... |
correct output |
---|
485 569 557 653 321 748 277 12... |
user output |
---|
452 418 234 209 495 287 522 36... |
Test 45
Verdict: WRONG ANSWER
input |
---|
900 3 211 842 343 877 364 381 214 ... |
correct output |
---|
335 639 155 81 727 888 416 752... |
user output |
---|
135 9 399 168 214 19 72 360 74... |
Test 46
Verdict: WRONG ANSWER
input |
---|
900 685 497 629 389 831 507 57 228... |
correct output |
---|
425 843 342 667 650 180 448 57... |
user output |
---|
40 475 180 448 894 381 638 855... |
Test 47
Verdict: WRONG ANSWER
input |
---|
900 158 489 267 475 847 29 542 314... |
correct output |
---|
467 792 741 221 125 49 266 887... |
user output |
---|
818 859 147 753 579 627 674 73... |
Test 48
Verdict: WRONG ANSWER
input |
---|
1000 588 544 250 749 769 456 423 98... |
correct output |
---|
329 138 847 4 250 240 598 786 ... |
user output |
---|
557 1000 656 217 998 497 670 2... |
Test 49
Verdict: WRONG ANSWER
input |
---|
1000 998 174 882 645 585 920 107 17... |
correct output |
---|
180 42 847 338 228 166 612 827... |
user output |
---|
113 654 906 960 564 400 936 15... |
Test 50
Verdict: WRONG ANSWER
input |
---|
1000 805 235 974 610 433 854 903 20... |
correct output |
---|
126 86 658 500 711 231 921 615... |
user output |
---|
617 74 883 29 937 19 356 117 9... |
Test 51
Verdict: WRONG ANSWER
input |
---|
1000 598 148 206 204 622 95 358 928... |
correct output |
---|
296 283 952 288 354 907 915 77... |
user output |
---|
828 784 874 271 377 979 741 21... |
Test 52
Verdict: WRONG ANSWER
input |
---|
1000 490 683 469 136 805 544 246 51... |
correct output |
---|
31 957 649 565 32 475 315 811 ... |
user output |
---|
680 624 3 775 593 714 834 24 8... |
Test 53
Verdict: WRONG ANSWER
input |
---|
100000 4944 311 69209 28682 87084 233... |
correct output |
---|
78792 8393 13826 63615 17735 1... |
user output |
---|
52913 86293 86217 79754 73583 ... |
Test 54
Verdict: WRONG ANSWER
input |
---|
100000 34704 25911 59988 65186 29855 ... |
correct output |
---|
44265 90477 6685 27459 49090 5... |
user output |
---|
61159 1688 82011 58305 44337 3... |
Test 55
Verdict: WRONG ANSWER
input |
---|
100000 32646 4868 34091 77349 54878 6... |
correct output |
---|
69142 94411 68862 51664 42109 ... |
user output |
---|
26227 3754 44512 37455 36143 6... |
Test 56
Verdict: WRONG ANSWER
input |
---|
100000 50383 56465 63211 49461 99139 ... |
correct output |
---|
95420 71427 95626 67011 82375 ... |
user output |
---|
14381 67584 41332 99873 21207 ... |
Test 57
Verdict: WRONG ANSWER
input |
---|
100000 94540 25313 57758 7201 51119 4... |
correct output |
---|
79187 70032 63831 69384 51604 ... |
user output |
---|
33992 2814 21255 54359 43375 6... |
Test 58
Verdict: ACCEPTED
input |
---|
100000 14300 28427 96935 52311 13463 ... |
correct output |
---|
5395 57047 3087 83662 90503 24... |
user output |
---|
5395 57047 3087 83662 90503 24... |
Test 59
Verdict: WRONG ANSWER
input |
---|
100000 14543 20265 6813 97256 2007 32... |
correct output |
---|
16434 64136 27052 56089 37320 ... |
user output |
---|
47492 70401 29051 7563 61584 7... |
Test 60
Verdict: WRONG ANSWER
input |
---|
100000 87233 22493 10433 86194 52186 ... |
correct output |
---|
62003 25428 66260 57053 59291 ... |
user output |
---|
6489 94683 5292 54662 43388 63... |
Test 61
Verdict: WRONG ANSWER
input |
---|
100000 83612 41781 34903 19741 34951 ... |
correct output |
---|
29843 44886 70357 52228 52247 ... |
user output |
---|
63438 6086 61860 727 90500 361... |
Test 62
Verdict: WRONG ANSWER
input |
---|
99995 1 2 2 4 4 6 6 8 8 10 10 12 12 ... |
correct output |
---|
99995 49998 99994 49997 99993 ... |
user output |
---|
99995 99994 99993 99992 99991 ... |
Test 63
Verdict: ACCEPTED
input |
---|
100000 1 2 3 4 5 6 7 8 9 10 11 12 13 ... |
correct output |
---|
100000 99999 99998 99997 99996... |
user output |
---|
100000 99999 99998 99997 99996... |