QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#499828 | #1139. Stations | Dan4Life | 0 | 46ms | 3884kb | C++23 | 1.3kb | 2024-07-31 19:31:41 | 2024-07-31 19:31:47 |
Judging History
stations
#include "stations.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 1010;
int dfs_timer = 0;
vi labels, adj[mxN];
void dfs(int s, int p, int dep){
dfs_timer++;
if(!dep) labels[s] = dfs_timer;
for(auto u : adj[s])
if(u!=p) dfs(u,s,dep^1);
dfs_timer++;
if(dep) labels[s] = dfs_timer;
}
vi label(int n, int k, vi u, vi v) {
labels.clear(); labels.resize(n,0); dfs_timer=0;
for(int i = 0; i < n; i++) adj[i].clear();
for(int i = 0; i < sz(u); i++){
int a = u[i], b = v[i];
adj[a].pb(b), adj[b].pb(a);
}
dfs(0,-1, 0); vi lol; lol.clear();
for(auto u : labels) lol.pb(u);
sort(all(lol)); lol.erase(unique(all(lol)),end(lol));
for(auto &u : labels) u=lower_bound(all(lol),u)-begin(lol)+1;
return labels;
}
int find_next_station(int s, int t, vi c) {
if(sz(c)==1) return c[0];
for(auto u : c) if(u==t) return u;
if(s < c[0]){
if(!s or (s<=t and t<=end(c)[-2]+1)){
for(int i = 1; i < sz(c)-!!s; i++)
if(c[i-1]+1<=t and t<=c[i]) return c[i];
return c[0];
}
return c.back();
}
if(c[1]-1<=t and t<=s){
for(int i = 1; i < sz(c)-1; i++)
if(c[i]<=t and t<=c[i+1]-1) return c[i];
return c.back();
}
return c[0];
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 36ms
memory: 3788kb
input:
0 10 10 1000 4 5 9 0 2 6 5 2 8 3 1 4 8 1 6 0 3 7 3 1000 0 1 1 2 998 1000 166 178 393 452 389 179 622 429 892 866 872 18 899 227 835 637 587 769 504 386 369 577 65 441 523 17 803 221 878 321 637 892 696 473 16 146 840 322 495 986 353 275 330 585 831 402 719 810 704 830 780 940 53 901 894 911 394 482 ...
output:
10 1 8 3 7 4 9 10 6 5 2 3 1 3 2 998 1 996 193 116 364 518 925 923 44 53 943 843 70 714 414 77 884 245 450 848 676 818 327 764 311 753 469 591 519 270 214 688 707 757 598 938 337 164 533 654 980 107 954 122 267 626 230 163 921 349 814 180 653 396 402 656 108 42 975 344 11 549 171 986 31 90 72 192 389...
input:
1 59784 1 2 1 2 575 619 2 843 844 1 2 1 2 849 311 2 152 153 3 2 1 2 2 1 1 1 1 2 1 2 743 154 2 675 676 2 1 2 3 4 1 4 1 4 475 417 2 526 527 10 3 2 1 3 224 889 2 196 197 935 401 2 66 67 733 50 2 113 114 286 438 2 715 716 1 2 1 2 70 53 2 77 78 3 2 2 1 2 1 2 1 2 648 64 2 569 570 2 1 1 1 38 863 2 571 572 ...
output:
2 843 2 153 2 1 2 675 4 4 527 3 196 67 113 715 2 78 2 2 569 1 572 2 3 308 2 1 1 349 25 862 2 10 94 1 406 28 9 4 10 169 580 999 19 768 896 476 81 81 3 44 151 2 3 3 2 615 3 3 1 1 727 195 468 7 243 1 1 352 451 235 132 1 217 273 3 2 992 2 2 471 3 88 3 12 82 571 10 10 10 3 2 3 2 171 218 474 3 384 395 313...
result:
wrong answer Diff at 378-th number: read 3 but expected 1
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 32ms
memory: 3812kb
input:
0 10 996 1000 0 1 2 0 1 3 4 1 5 2 6 2 7 3 3 8 4 9 10 4 11 5 12 5 6 13 14 6 7 15 7 16 17 8 18 8 19 9 9 20 21 10 10 22 23 11 24 11 12 25 26 12 27 13 13 28 14 29 30 14 15 31 15 32 16 33 34 16 35 17 17 36 18 37 38 18 39 19 40 19 41 20 42 20 43 21 44 21 45 22 46 22 23 47 48 23 49 24 24 50 25 51 52 25 26 ...
output:
996 1 512 996 2 257 513 768 129 256 384 511 640 767 895 995 3 66 130 193 258 321 385 448 514 577 641 704 769 832 896 959 34 65 97 128 161 192 224 255 289 320 352 383 416 447 479 510 545 576 608 639 672 703 735 766 800 831 863 894 927 958 979 994 4 19 35 50 67 82 98 113 131 146 162 177 194 209 225 24...
input:
1 50252 730 382 1 728 853 131 1 852 987 524 1 988 410 386 1 409 858 223 1 856 422 925 1 421 708 714 1 706 435 779 1 433 713 754 3 714 715 719 871 464 3 864 865 868 993 16 1 994 597 144 3 598 599 600 783 517 1 781 404 923 1 402 292 1 1 291 72 148 1 71 865 932 3 866 867 871 320 311 3 258 290 305 362 6...
output:
728 852 988 409 856 421 706 433 719 864 994 600 781 402 291 71 871 305 361 961 936 865 713 161 376 916 210 759 684 927 896 886 774 361 290 506 610 770 301 460 855 409 982 904 415 49 169 688 841 138 169 369 923 54 840 977 333 939 631 232 687 901 188 443 865 650 448 102 267 213 752 688 601 96 997 895 ...
result:
wrong answer Diff at 23801-th number: read 572 but expected 561
Subtask #3:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 36ms
memory: 3812kb
input:
0 10 2 1000000 1 0 997 1000000 830 513 223 672 727 200 763 415 581 440 34 42 267 325 912 693 753 59 401 289 198 641 982 214 41 49 453 107 940 806 905 732 153 482 248 405 102 79 480 837 534 620 564 856 679 178 278 247 899 206 333 672 297 308 407 863 26 752 272 178 204 603 208 10 715 562 785 285 184 5...
output:
2 1 2 997 1 739 651 290 829 151 602 719 191 19 535 58 986 316 243 229 961 989 842 906 784 622 92 646 87 944 336 395 311 665 878 12 827 171 562 677 199 114 42 354 954 786 303 747 795 295 461 480 612 79 137 57 150 366 152 368 956 400 560 507 294 285 307 433 858 897 689 924 401 547 2 287 22 432 6 647 5...
input:
1 59859 6 4 2 1 2 2 1 1 1 2 1 1 1 985 958 2 16 17 195 246 2 900 901 136 435 2 868 869 1 2 1 2 7 1 2 9 10 62 165 2 939 940 1 2 1 2 1 2 1 2 2 1 1 1 3 2 2 1 2 881 88 2 980 981 815 894 2 186 187 745 749 2 256 257 5 10 2 2 3 2 3 1 3 718 613 2 147 148 24 99 2 92 93 281 294 2 723 724 855 430 2 240 241 920 ...
output:
2 1 1 17 900 868 2 10 939 2 2 1 2 981 186 256 2 3 148 93 723 241 942 921 2 531 264 349 3 2 322 1 274 4 1 2 687 164 399 2 188 351 939 322 3 4 588 637 559 2 162 4 277 385 68 71 2 25 1 1 3 6 6 38 747 416 28 4 161 7 135 615 42 4 786 2 615 378 2 791 3 469 741 2 2 80 2 860 2 654 78 7 3 3 182 5 3 2 850 2 4...
result:
wrong answer Diff at 1090-th number: read 6 but expected 10
Subtask #4:
score: 0
Wrong Answer
Test #34:
score: 10
Accepted
time: 46ms
memory: 3744kb
input:
0 10 2 1000000000 0 1 2 1000000000 0 1 2 1000000000 1 0 2 1000000000 1 0 2 1000000000 0 1 2 1000000000 1 0 2 1000000000 1 0 2 1000000000 0 1 2 1000000000 0 1 2 1000000000 0 1
output:
2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2
input:
1 100000 2 1 1 1 1 2 1 2 1 2 1 2 2 1 1 1 1 2 1 2 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1 1 1 1 2 1 2 2 1 1 1 1 2 1 2 1 2 1 2 1 2 1 2 2 1 1 1 2 1 1 1 1 2 1 2 2 1 1 1 1 2 1 2 1 2 1 2 2 1 1 1 2 1 1 1 1 2 1 2 1 2 1 2 2 1 1 1 1 2 1 2 1 2 1 2 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1...
output:
1 2 2 1 2 1 1 1 1 1 2 1 2 1 2 2 2 1 1 2 1 2 2 1 1 2 2 1 2 2 1 1 1 1 1 2 1 2 1 1 1 2 2 1 2 2 2 2 1 1 2 2 1 1 1 2 2 1 2 2 1 2 2 1 1 1 2 1 2 2 2 2 2 2 1 2 1 2 2 2 1 1 1 1 2 1 1 2 1 2 2 1 2 2 2 1 1 1 2 2 2 1 2 1 1 2 1 2 1 2 2 1 1 2 1 1 1 2 2 2 1 1 1 2 2 1 1 2 2 2 1 2 1 2 1 2 2 2 2 1 1 1 1 2 1 1 2 1 1 1 ...
result:
ok
Test #35:
score: 10
Accepted
time: 38ms
memory: 3768kb
input:
0 10 3 1000000000 2 1 2 0 3 1000000000 1 0 2 0 3 1000000000 2 0 0 1 3 1000000000 0 2 1 2 3 1000000000 1 2 1 0 3 1000000000 1 0 2 1 3 1000000000 0 2 1 2 3 1000000000 1 2 1 0 3 1000000000 0 2 1 0 3 1000000000 2 0 1 2
output:
3 1 2 3 3 1 2 3 3 1 3 2 3 1 2 3 3 1 3 2 3 1 3 2 3 1 2 3 3 1 3 2 3 1 3 2 3 1 2 3
input:
1 75069 3 2 2 1 2 1 2 2 2 3 1 2 1 3 1 2 1 3 2 1 1 1 1 2 1 3 2 3 1 3 3 1 2 1 2 2 3 1 1 3 2 2 1 2 3 2 2 1 2 2 1 1 3 3 2 2 1 2 3 2 2 1 2 2 1 1 3 1 2 1 3 3 1 2 1 2 1 2 2 2 3 1 3 1 3 2 3 1 3 3 2 2 1 2 3 2 2 1 2 2 1 1 1 2 3 1 3 1 3 1 3 2 1 1 3 1 3 1 3 2 1 1 1 2 1 1 3 3 1 2 1 2 3 2 2 1 2 1 2 2 2 3 3 1 2 1 ...
output:
2 2 3 3 1 3 3 1 1 2 2 3 2 2 3 3 1 2 3 3 2 2 1 3 3 3 3 1 3 1 2 2 1 3 1 3 1 2 3 1 3 3 1 3 1 1 3 3 1 1 3 2 1 3 3 3 3 3 1 3 2 3 3 2 1 2 1 3 2 3 2 3 3 3 2 3 1 1 1 2 1 1 3 1 1 1 2 3 3 1 3 3 2 2 2 3 2 1 2 3 1 1 3 1 1 2 1 2 3 1 2 3 3 1 3 3 1 3 3 3 3 1 2 2 1 3 3 3 2 1 3 1 3 1 2 3 3 2 3 3 1 3 2 3 1 1 1 3 3 3 ...
result:
ok
Test #36:
score: 0
Wrong Answer
time: 36ms
memory: 3808kb
input:
0 10 4 1000000000 3 1 2 0 1 0 4 1000000000 0 3 1 2 3 1 4 1000000000 3 1 0 2 0 1 4 1000000000 2 1 2 3 1 0 4 1000000000 3 1 0 1 2 3 4 1000000000 0 1 3 0 2 3 4 1000000000 2 0 3 0 1 2 4 1000000000 0 2 2 3 1 3 4 1000000000 3 2 2 1 3 0 4 1000000000 2 3 3 0 0 1
output:
4 1 4 2 3 4 1 2 3 4 4 1 4 2 3 4 1 4 2 3 4 1 4 3 2 4 1 2 3 4 4 1 2 3 4 4 1 3 4 2 4 1 3 2 4 4 1 4 2 3
input:
1 66804 1 2 2 3 4 1 2 2 3 4 4 1 2 1 3 1 4 1 4 1 3 2 2 4 4 3 2 1 3 2 3 2 3 4 4 2 2 1 2 1 2 1 4 3 4 2 1 2 1 4 2 2 4 4 1 2 1 3 2 4 2 3 4 2 1 1 1 4 1 2 1 2 2 3 1 1 2 1 1 1 4 3 2 1 3 2 4 2 3 4 3 2 1 2 2 3 2 3 4 4 1 1 1 1 4 1 4 4 3 2 1 2 3 2 1 2 4 2 2 1 3 4 1 2 1 2 3 2 1 2 3 2 1 2 1 2 2 2 4 4 3 2 1 3 3 4 ...
output:
3 3 1 4 2 3 3 2 4 1 4 1 4 1 1 1 1 3 4 2 3 1 4 2 2 3 1 2 2 2 3 2 2 1 4 4 4 2 4 2 1 2 4 2 4 1 4 4 4 2 3 3 2 3 3 2 2 4 3 1 4 1 4 3 2 1 4 2 4 4 4 1 4 4 3 1 3 1 1 2 2 4 4 4 3 1 2 4 2 2 1 2 2 1 4 4 4 2 1 4 2 1 3 2 2 4 2 2 4 2 3 1 4 1 1 1 4 2 3 3 4 2 4 4 3 2 2 2 3 4 3 1 4 4 2 4 3 2 3 3 3 4 4 1 1 1 2 1 4 4 ...
result:
wrong answer Diff at 5-th number: read 2 but expected 4
Subtask #5:
score: 0
Wrong Answer
Test #54:
score: 0
Wrong Answer
time: 34ms
memory: 3884kb
input:
0 10 3 1000000000 1 0 2 1 998 1000000000 928 443 90 795 55 379 957 417 759 300 960 136 309 858 833 370 228 827 876 955 619 365 15 108 243 388 54 925 141 894 272 634 0 989 600 346 380 277 350 113 326 613 975 946 660 98 34 538 220 864 9 585 185 860 458 424 509 14 22 275 109 872 153 233 76 834 972 736 ...
output:
3 1 3 2 998 1 270 942 743 640 71 785 569 992 366 92 445 982 460 418 660 88 65 563 27 295 160 726 820 813 32 112 626 918 783 971 627 790 692 371 231 322 462 702 959 7 352 583 670 829 380 572 494 230 159 241 39 316 28 206 250 489 833 180 200 912 430 329 449 277 38 787 507 382 695 9 191 622 658 420 884...
input:
1 59797 2 3 2 3 4 267 314 2 494 495 2 1 1 1 65 33 2 49 50 108 783 2 381 382 4 1 2 1 2 4 3 2 1 2 263 411 2 939 940 771 972 2 716 717 783 708 2 361 362 1 2 1 2 509 505 2 252 253 562 198 2 199 200 975 878 2 227 228 3 1 2 1 2 906 605 2 238 239 743 542 2 258 259 20 27 2 94 95 6 7 2 7 8 913 678 2 88 89 47...
output:
3 494 1 49 382 1 2 939 716 362 2 253 199 228 1 239 259 94 7 89 530 1 4 525 110 548 827 906 774 2 1 108 189 3 752 23 48 874 73 1 3 2 615 933 1 437 653 314 516 6 2 54 491 1 9 623 538 2 890 4 2 339 4 10 301 55 4 626 117 3 6 910 100 422 913 676 2 462 592 685 3 67 3 4 8 694 608 306 2 4 160 3 6 281 2 2 99...
result:
wrong answer Diff at 180-th number: read 3 but expected 10