| Task: | HDRF |
| Sender: | On |
| Submission time: | 2017-03-09 13:17:54 +0200 |
| Language: | C++ |
| Status: | READY |
| Result: | 0 |
| group | verdict | score |
|---|---|---|
| #1 | WRONG ANSWER | 0 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.04 s | details |
| #2 | WRONG ANSWER | 0.04 s | details |
| #3 | WRONG ANSWER | 0.04 s | details |
| #4 | WRONG ANSWER | 0.06 s | details |
| #5 | WRONG ANSWER | 0.03 s | details |
| #6 | WRONG ANSWER | 0.05 s | details |
| #7 | WRONG ANSWER | 0.04 s | details |
| #8 | WRONG ANSWER | 0.03 s | details |
| #9 | ACCEPTED | 0.04 s | details |
| #10 | WRONG ANSWER | 0.04 s | details |
| #11 | WRONG ANSWER | 0.04 s | details |
| #12 | WRONG ANSWER | 0.03 s | details |
| #13 | WRONG ANSWER | 0.05 s | details |
| #14 | WRONG ANSWER | 0.05 s | details |
| #15 | WRONG ANSWER | 0.04 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.04 s | details |
| #20 | WRONG ANSWER | 0.04 s | details |
| #21 | WRONG ANSWER | 0.03 s | details |
| #22 | WRONG ANSWER | 0.05 s | details |
| #23 | WRONG ANSWER | 0.04 s | details |
| #24 | WRONG ANSWER | 0.04 s | details |
| #25 | WRONG ANSWER | 0.04 s | details |
| #26 | WRONG ANSWER | 0.04 s | details |
| #27 | WRONG ANSWER | 0.04 s | details |
| #28 | WRONG ANSWER | 0.04 s | details |
| #29 | WRONG ANSWER | 0.03 s | details |
| #30 | WRONG ANSWER | 0.04 s | details |
| #31 | WRONG ANSWER | 0.04 s | details |
| #32 | WRONG ANSWER | 0.04 s | details |
| #33 | WRONG ANSWER | 0.04 s | details |
| #34 | WRONG ANSWER | 0.04 s | details |
| #35 | WRONG ANSWER | 0.05 s | details |
| #36 | WRONG ANSWER | 0.04 s | details |
| #37 | WRONG ANSWER | 0.04 s | details |
| #38 | WRONG ANSWER | 0.04 s | details |
| #39 | WRONG ANSWER | 0.05 s | details |
| #40 | WRONG ANSWER | 0.04 s | details |
| #41 | WRONG ANSWER | 0.04 s | details |
| #42 | WRONG ANSWER | 0.04 s | details |
| #43 | WRONG ANSWER | 0.04 s | details |
| #44 | WRONG ANSWER | 0.04 s | details |
| #45 | WRONG ANSWER | 0.03 s | details |
| #46 | WRONG ANSWER | 0.03 s | details |
| #47 | WRONG ANSWER | 0.03 s | details |
| #48 | WRONG ANSWER | 0.05 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.11 s | details |
| #54 | WRONG ANSWER | 0.10 s | details |
| #55 | WRONG ANSWER | 0.08 s | details |
| #56 | WRONG ANSWER | 0.09 s | details |
| #57 | WRONG ANSWER | 0.09 s | details |
| #58 | ACCEPTED | 0.09 s | details |
| #59 | WRONG ANSWER | 0.10 s | details |
| #60 | WRONG ANSWER | 0.08 s | details |
| #61 | WRONG ANSWER | 0.11 s | details |
| #62 | WRONG ANSWER | 0.07 s | details |
| #63 | ACCEPTED | 0.08 s | details |
Code
#include <bits/stdc++.h>
using namespace std;
int n, t;
vector<vector<int>> v;
vector<int> w, r;
vector<bool> z;
void f(int x) {
if(z[x]) return;
z[x] = true;
if(v[x].size() > 0) {
for(auto i : v[x]) f(i);
r.push_back(x);
return;
}
r.push_back(x);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n;
v.resize(n);
w.resize(n);
z.resize(n);
for(int i = 0; i < n-1; i++) {
cin >> t;
v[t-1].push_back(i+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) {
return w[b] > w[a];
});
}
f(0);
for(auto i : r) 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 |
|---|
| 30 96 68 62 3 60 42 69 35 53 1... |
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 |
|---|
| 93 72 43 9 49 70 13 69 66 7 75... |
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 50 20 53 21 84 83 57 ... |
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 |
|---|
| 87 78 5 81 36 58 86 67 28 26 7... |
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 40 53 3 22 54 36 8... |
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 |
|---|
| 7 32 106 170 185 11 90 33 135 ... |
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 |
|---|
| 58 21 121 107 74 151 115 85 49... |
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 |
|---|
| 5 26 187 183 11 70 149 116 126... |
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 |
|---|
| 193 63 92 184 93 17 132 40 133... |
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 |
|---|
| 189 283 203 271 57 218 293 29 ... |
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 |
|---|
| 8 232 49 174 179 56 135 42 169... |
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 |
|---|
| 104 181 41 130 53 188 52 56 21... |
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 149 19 290 6 159 13 16 ... |
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 156 39 34 241 27... |
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 |
|---|
| 332 11 367 343 346 269 278 14 ... |
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 |
|---|
| 19 181 364 60 106 279 280 197 ... |
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 |
|---|
| 87 26 316 325 277 372 64 44 29... |
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 |
|---|
| 45 377 222 19 344 277 39 55 37... |
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 |
|---|
| 355 293 177 353 193 146 269 88... |
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 |
|---|
| 31 111 181 33 47 230 464 46 40... |
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 |
|---|
| 458 332 281 37 70 196 122 85 1... |
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 |
|---|
| 367 47 313 449 429 159 123 113... |
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 |
|---|
| 74 185 380 442 20 66 428 164 4... |
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 147 433 179 107 306 35... |
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 |
|---|
| 132 341 396 108 334 219 560 25... |
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 |
|---|
| 195 352 520 383 429 315 445 29... |
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 |
|---|
| 137 129 456 345 444 209 202 58... |
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 |
|---|
| 46 207 143 309 444 195 539 593... |
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 |
|---|
| 540 16 443 442 14 410 170 281 ... |
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 257 ... |
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 |
|---|
| 518 52 679 267 279 308 107 201... |
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 |
|---|
| 145 689 470 494 139 371 316 34... |
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 |
|---|
| 132 460 143 613 218 547 57 690... |
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 473 348 484 36 349... |
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 |
|---|
| 331 426 34 173 523 150 230 271... |
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 |
|---|
| 472 403 645 432 120 133 201 71... |
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 |
|---|
| 723 709 367 394 663 628 365 13... |
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 135 8 219 479 657 565 205 2... |
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 |
|---|
| 654 248 449 725 338 581 319 45... |
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 |
|---|
| 354 839 370 160 638 879 570 76... |
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 |
|---|
| 347 395 121 466 483 493 94 656... |
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 |
|---|
| 258 199 455 315 483 5 377 343 ... |
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 |
|---|
| 295 630 320 589 105 522 26 380... |
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 339 737 359 239 68... |
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 |
|---|
| 612 174 659 118 326 324 795 11... |
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 |
|---|
| 953 422 466 679 931 113 654 86... |
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 |
|---|
| 462 966 101 781 948 102 367 72... |
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 |
|---|
| 359 455 50 127 495 512 195 683... |
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 |
|---|
| 333 180 192 889 461 146 933 51... |
Test 53
Verdict: WRONG ANSWER
| input |
|---|
| 100000 4944 311 69209 28682 87084 233... |
| correct output |
|---|
| 78792 8393 13826 63615 17735 1... |
| user output |
|---|
| 29660 31268 9433 96240 76017 9... |
Test 54
Verdict: WRONG ANSWER
| input |
|---|
| 100000 34704 25911 59988 65186 29855 ... |
| correct output |
|---|
| 44265 90477 6685 27459 49090 5... |
| user output |
|---|
| 39373 20892 11878 785 76554 54... |
Test 55
Verdict: WRONG ANSWER
| input |
|---|
| 100000 32646 4868 34091 77349 54878 6... |
| correct output |
|---|
| 69142 94411 68862 51664 42109 ... |
| user output |
|---|
| 50968 26227 3754 44512 37455 3... |
Test 56
Verdict: WRONG ANSWER
| input |
|---|
| 100000 50383 56465 63211 49461 99139 ... |
| correct output |
|---|
| 95420 71427 95626 67011 82375 ... |
| user output |
|---|
| 14381 67584 68294 22108 21320 ... |
Test 57
Verdict: WRONG ANSWER
| input |
|---|
| 100000 94540 25313 57758 7201 51119 4... |
| correct output |
|---|
| 79187 70032 63831 69384 51604 ... |
| user output |
|---|
| 20647 81099 86977 9867 92668 1... |
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 |
|---|
| 87114 33727 47492 70401 29051 ... |
Test 60
Verdict: WRONG ANSWER
| input |
|---|
| 100000 87233 22493 10433 86194 52186 ... |
| correct output |
|---|
| 62003 25428 66260 57053 59291 ... |
| user output |
|---|
| 98705 39671 6042 61852 57438 9... |
Test 61
Verdict: WRONG ANSWER
| input |
|---|
| 100000 83612 41781 34903 19741 34951 ... |
| correct output |
|---|
| 29843 44886 70357 52228 52247 ... |
| user output |
|---|
| 99494 77741 69254 26564 19721 ... |
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... |
