QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216753 | #5132. House Numbering | MovingUp# | AC ✓ | 92ms | 35532kb | C++14 | 1.9kb | 2023-10-15 22:15:12 | 2023-10-15 22:15:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
int n, h[maxn], start[maxn];
bool in_cycle[maxn], vis[maxn];
vector<pair<int, int>> adj[maxn];
set<int> se[maxn];
vector<int> stk, cycle;
bool good;
bool dfs(int v, int p) {
vis[v] = true;
stk.push_back(v);
for (auto [to, id] : adj[v]) {
if (to == p) {
continue;
}
if (vis[to]) {
int cur = v;
while (true) {
cur = stk.back();
in_cycle[cur] = true;
cycle.push_back(cur);
stk.pop_back();
if (cur == to) {
break;
}
}
return true;
} else {
if (dfs(to, v)) {
return true;
}
}
}
stk.pop_back();
return false;
}
void try_ins(int v, int value) {
if (se[v].count(value)) {
good = false;
}
se[v].insert(value);
}
void dfs_tree(int v, int p) {
vis[v] = true;
for (auto [to, id] : adj[v]) {
if (to == p || in_cycle[to]) {
continue;
}
start[id] = to;
try_ins(to, 1);
try_ins(v, h[id]);
if (!vis[to]) {
dfs_tree(to, v);
}
}
}
bool go(int diff) {
good = true;
for (int i = 1; i <= n; i++) {
se[i].clear();
}
memset(vis, 0, sizeof vis);
int C = cycle.size();
for (int i = 0; i < C; i++) {
int v = cycle[i];
vis[v] = true;
int nxt = cycle[(i + diff + C) % C];
for (auto [to, id] : adj[v]) {
if (to == nxt) {
start[id] = v;
try_ins(v, 1);
try_ins(to, h[id]);
}
}
}
for (int v : cycle) {
dfs_tree(v, -1);
}
return good;
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(0);
cin >> n;
for (int i = 1; i <= n; i++) {
int a, b;
cin >> a >> b >> h[i];
adj[a].push_back({b, i});
adj[b].push_back({a, i});
}
dfs(1, -1);
if (!go(1)) {
if (!go(-1)) {
cout << "impossible\n";
return 0;
}
}
for (int i = 1; i <= n; i++) {
cout << start[i] << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 11076kb
input:
3 1 2 2 2 3 9 3 1 3
output:
2 3 1
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 11088kb
input:
4 1 2 2 1 3 2 2 3 2 1 4 2
output:
impossible
result:
ok
Test #3:
score: 0
Accepted
time: 2ms
memory: 10768kb
input:
3 3 2 2 2 1 2 1 3 2
output:
3 2 1
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 10696kb
input:
3 1 3 374 3 2 519 2 1 549
output:
3 2 1
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 10832kb
input:
1000 960 606 2 606 278 2 278 118 2 118 965 2 965 546 2 546 518 2 518 758 2 758 32 2 32 839 2 839 245 2 245 201 2 201 353 2 353 386 2 386 737 2 737 420 2 420 838 2 838 493 2 493 905 2 905 704 2 704 563 2 563 687 2 687 218 2 218 739 2 739 544 2 544 548 2 548 442 2 442 744 2 744 724 2 724 640 2 640 767...
output:
960 606 278 118 965 546 518 758 32 839 245 201 353 386 737 420 838 493 905 704 563 687 218 739 544 548 442 744 724 640 767 816 164 154 231 211 788 686 599 715 410 759 521 121 585 148 158 854 603 344 966 242 458 852 709 592 880 902 629 680 867 469 703 957 84 396 509 319 942 972 238 358 932 692 145 84...
result:
ok
Test #6:
score: 0
Accepted
time: 3ms
memory: 10776kb
input:
1000 758 943 361 943 940 927 940 267 37 267 932 61 932 503 811 503 851 961 851 759 727 759 553 953 553 327 963 327 766 814 766 146 790 146 219 456 219 751 418 751 594 395 594 355 506 355 800 556 800 487 448 487 154 412 154 152 12 152 418 767 418 538 525 538 353 651 353 964 296 964 346 516 346 139 14...
output:
758 943 940 267 932 503 851 759 553 327 766 146 219 751 594 355 800 487 154 152 418 538 353 964 346 139 6 527 485 836 814 24 118 537 603 409 573 589 848 492 394 973 960 279 955 531 291 611 995 864 384 632 464 870 507 561 968 583 969 432 404 510 296 840 285 998 141 727 637 466 802 477 111 592 630 434...
result:
ok
Test #7:
score: 0
Accepted
time: 7ms
memory: 13100kb
input:
10000 3186 2782 2 2782 298 2 298 5102 2 5102 7844 2 7844 2121 2 2121 1327 2 1327 963 2 963 1476 2 1476 6796 2 6796 2601 2 2601 3663 2 3663 537 2 537 7009 2 7009 8359 2 8359 9182 2 9182 3559 2 3559 2818 2 2818 3174 2 3174 1350 2 1350 3944 2 3944 4620 2 4620 7832 2 7832 7007 2 7007 8636 2 8636 131 2 1...
output:
3186 2782 298 5102 7844 2121 1327 963 1476 6796 2601 3663 537 7009 8359 9182 3559 2818 3174 1350 3944 4620 7832 7007 8636 131 1774 2430 2023 4765 599 1384 7695 6664 5795 7263 2886 4772 1005 9465 4003 7943 5695 8458 9611 8537 1365 4295 9147 7347 4046 4230 6230 6636 7518 8450 1611 6158 5896 9895 8102 ...
result:
ok
Test #8:
score: 0
Accepted
time: 3ms
memory: 13488kb
input:
10000 3852 8753 857 8753 6570 997 6570 8378 337 8378 6838 253 6838 6832 801 6832 1443 879 1443 5821 206 5821 9332 690 9332 481 638 481 4466 88 4466 9433 464 9433 1713 258 1713 5136 243 5136 1300 962 1300 4261 200 4261 599 974 599 6852 651 6852 7430 162 7430 6058 474 6058 1914 235 1914 6049 128 6049 ...
output:
3852 8753 6570 8378 6838 6832 1443 5821 9332 481 4466 9433 1713 5136 1300 4261 599 6852 7430 6058 1914 6049 3935 9278 8520 3551 5041 4622 8693 4680 6652 2051 7185 6381 9164 7385 9627 7285 2680 3167 141 8850 9498 8900 1510 5471 2901 7697 5285 8881 6603 7404 1217 6444 6526 6581 6681 2582 7581 8204 316...
result:
ok
Test #9:
score: 0
Accepted
time: 51ms
memory: 35372kb
input:
100000 49761 50860 2 50860 76368 2 76368 36060 2 36060 38900 2 38900 8477 2 8477 16539 2 16539 1834 2 1834 41645 2 41645 11420 2 11420 52011 2 52011 70194 2 70194 5318 2 5318 90571 2 90571 25209 2 25209 36177 2 36177 83455 2 83455 97871 2 97871 76892 2 76892 50332 2 50332 70903 2 70903 94195 2 94195...
output:
49761 50860 76368 36060 38900 8477 16539 1834 41645 11420 52011 70194 5318 90571 25209 36177 83455 97871 76892 50332 70903 94195 61933 31177 21238 74820 99490 26047 31858 62948 29778 16892 94302 43724 37400 7932 2470 72838 51206 80051 39672 58583 92664 52368 19444 65620 76657 6056 6878 13492 61144 8...
result:
ok
Test #10:
score: 0
Accepted
time: 47ms
memory: 35532kb
input:
100000 99597 2401 4114 2401 31522 8636 31522 5447 6268 5447 81737 4594 81737 33124 9354 33124 45703 4433 45703 11371 2069 11371 32023 3251 32023 75309 630 75309 41612 2093 41612 72484 2539 72484 68595 4051 68595 26179 3927 26179 32505 2939 32505 14017 7967 14017 41000 8122 41000 44698 9268 44698 135...
output:
99597 2401 31522 5447 81737 33124 45703 11371 32023 75309 41612 72484 68595 26179 32505 14017 41000 44698 13554 81437 38670 29915 4115 11545 96469 82271 25158 40706 64753 16741 29158 27028 68763 67221 3642 20953 1842 44974 18774 77786 74748 32518 18966 94057 17449 81693 77323 66374 53595 14432 2837 ...
result:
ok
Test #11:
score: 0
Accepted
time: 3ms
memory: 10712kb
input:
10 6 4 2 4 3 2 3 6 2 6 1 3 6 2 4 6 9 5 6 10 6 6 5 7 6 7 8 6 8 8
output:
impossible
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 10724kb
input:
10 5 3 2 3 8 2 8 5 2 5 2 3 5 6 4 5 7 5 5 9 6 5 1 7 5 4 8 5 10 9
output:
3 8 5 2 6 7 9 1 4 10
result:
ok
Test #13:
score: 0
Accepted
time: 4ms
memory: 11912kb
input:
10000 960 7551 2 7551 6364 2 6364 960 2 960 5654 3 960 2576 4 960 3869 5 960 4041 6 960 8097 7 960 5925 8 960 8942 9 960 7956 10 960 5679 11 960 7926 12 960 7225 13 960 1441 14 960 9198 15 960 2728 16 960 5234 17 960 9504 18 960 5978 19 960 8617 20 960 4722 21 960 9776 22 960 1438 23 960 8510 24 960...
output:
impossible
result:
ok
Test #14:
score: 0
Accepted
time: 8ms
memory: 11856kb
input:
10000 6892 5836 2 5836 8076 2 8076 6892 2 6892 41 3 6892 818 4 6892 1869 5 6892 9971 6 6892 8893 7 6892 8448 8 6892 8797 9 6892 4734 10 6892 6363 11 6892 2521 12 6892 6653 13 6892 6429 14 6892 9183 15 6892 4574 16 6892 6263 17 6892 5796 18 6892 8647 19 6892 6395 20 6892 1067 21 6892 9777 22 6892 459...
output:
5836 8076 6892 41 818 1869 9971 8893 8448 8797 4734 6363 2521 6653 6429 9183 4574 6263 5796 8647 6395 1067 9777 4595 235 5635 927 8834 1912 6402 2966 432 6508 5806 4877 907 2615 458 8254 1818 8999 8443 3380 4498 1173 9423 3712 2489 8615 3964 6068 3738 9939 5056 3577 9267 1710 4952 8510 1809 953 1476...
result:
ok
Test #15:
score: 0
Accepted
time: 92ms
memory: 24464kb
input:
100000 84225 28140 2 28140 64081 2 64081 84225 2 84225 3607 3 84225 79098 4 84225 54956 5 84225 56652 6 84225 10188 7 84225 71334 8 84225 28446 9 84225 54343 10 84225 16085 11 84225 8783 12 84225 48459 13 84225 56054 14 84225 71712 15 84225 76633 16 84225 35106 17 84225 41707 18 84225 21811 19 84225...
output:
impossible
result:
ok
Test #16:
score: 0
Accepted
time: 58ms
memory: 24336kb
input:
100000 91433 48183 2 48183 98573 2 98573 91433 2 91433 20844 3 91433 52909 4 91433 64002 5 91433 34038 6 91433 14470 7 91433 8314 8 91433 86980 9 91433 44958 10 91433 80520 11 91433 17505 12 91433 68805 13 91433 48074 14 91433 98859 15 91433 16335 16 91433 52854 17 91433 40979 18 91433 82430 19 9143...
output:
48183 98573 91433 20844 52909 64002 34038 14470 8314 86980 44958 80520 17505 68805 48074 98859 16335 52854 40979 82430 49499 45108 83352 70703 8792 7553 83587 3230 99710 56070 34020 639 43646 98027 26327 65143 64023 49213 59721 98883 94961 92239 53016 99598 63728 61644 27760 27782 60713 45856 80862 ...
result:
ok
Test #17:
score: 0
Accepted
time: 69ms
memory: 30048kb
input:
100000 4643 71477 2 71477 78529 2 78529 97642 2 97642 88636 2 88636 19946 2 19946 11925 2 11925 2648 2 2648 7214 2 7214 90083 2 90083 39222 2 39222 79070 2 79070 69444 2 69444 36168 2 36168 4265 2 4265 57132 2 57132 12498 2 12498 47674 2 47674 92898 2 92898 98727 2 98727 36767 2 36767 73724 2 73724 ...
output:
impossible
result:
ok
Test #18:
score: 0
Accepted
time: 52ms
memory: 30052kb
input:
100000 57159 6315 2 6315 95767 2 95767 55984 2 55984 54114 2 54114 91071 2 91071 85044 2 85044 5160 2 5160 59261 2 59261 72861 2 72861 99866 2 99866 80777 2 80777 9040 2 9040 89828 2 89828 29646 2 29646 13953 2 13953 34849 2 34849 90489 2 90489 74896 2 74896 85077 2 85077 58369 2 58369 59655 2 59655...
output:
6315 95767 55984 54114 91071 85044 5160 59261 72861 99866 80777 9040 89828 29646 13953 34849 90489 74896 85077 58369 59655 45430 82354 70328 43180 87429 12105 6756 78957 29966 99968 40349 16161 58825 76325 89471 48132 46683 87118 93739 14093 16090 97019 65189 50496 32412 78286 55054 39959 34040 9401...
result:
ok
Test #19:
score: 0
Accepted
time: 61ms
memory: 34224kb
input:
100000 69460 3866 2 3866 96896 2 96896 72257 2 72257 45458 2 45458 70526 2 70526 98548 2 98548 91978 2 91978 22460 2 22460 76384 2 76384 13354 2 13354 65620 2 65620 39774 2 39774 39579 2 39579 86381 2 86381 69224 2 69224 88209 2 88209 68771 2 68771 87959 2 87959 73484 2 73484 9506 2 9506 20048 2 200...
output:
impossible
result:
ok
Test #20:
score: 0
Accepted
time: 49ms
memory: 34236kb
input:
100000 25768 64056 2 64056 92930 2 92930 83257 2 83257 43237 2 43237 43215 2 43215 97503 2 97503 60742 2 60742 42794 2 42794 67658 2 67658 55721 2 55721 439 2 439 29059 2 29059 46455 2 46455 29253 2 29253 23747 2 23747 89873 2 89873 93582 2 93582 25689 2 25689 40564 2 40564 37314 2 37314 67040 2 670...
output:
25768 64056 92930 83257 43237 43215 97503 60742 42794 67658 55721 439 29059 46455 29253 23747 89873 93582 25689 40564 37314 67040 578 88015 75945 78540 95394 12413 28451 1370 85685 9843 13929 66925 8616 31408 78954 89678 45490 26008 77312 6253 66387 53176 95418 63217 65029 34445 57418 45276 44933 93...
result:
ok
Test #21:
score: 0
Accepted
time: 2ms
memory: 10856kb
input:
4 1 2 2 2 3 2 3 1 2 4 1 2
output:
impossible
result:
ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 10788kb
input:
4 2 3 10 3 1 189 1 2 9 4 2 187
output:
2 3 1 4
result:
ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 10848kb
input:
40 32 25 2 25 18 2 18 4 2 4 26 2 26 11 2 11 37 2 37 9 2 9 5 2 5 36 2 36 3 2 3 31 2 31 28 2 28 39 2 39 12 2 12 16 2 16 15 2 15 20 2 20 19 2 19 40 2 40 32 2 24 19 2 38 39 2 33 31 2 30 33 2 8 33 2 6 8 2 35 36 2 7 36 2 22 8 2 10 32 2 29 19 2 27 20 2 34 11 2 1 28 2 2 26 2 23 19 2 17 8 2 21 7 2 13 2 2 14 ...
output:
impossible
result:
ok
Test #24:
score: 0
Accepted
time: 2ms
memory: 11060kb
input:
40 32 30 3 30 23 3 23 28 2 28 9 3 9 2 2 2 4 3 4 19 2 19 15 2 15 11 2 11 8 2 8 24 3 24 6 2 6 1 2 1 3 2 3 39 2 39 38 3 38 35 2 35 18 3 18 37 3 37 32 2 25 35 3 12 25 3 29 19 3 7 28 3 36 19 2 17 3 2 16 24 3 31 15 2 27 23 2 14 12 2 10 1 2 21 11 3 34 18 2 20 27 3 26 32 2 13 12 2 33 12 2 40 8 2 5 37 3 22 3...
output:
impossible
result:
ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 11400kb
input:
40 38 28 4 28 18 4 18 4 4 4 15 6 15 8 6 8 40 6 40 20 2 20 33 5 33 32 3 32 2 5 2 21 2 21 22 4 22 24 5 24 14 5 14 11 2 11 30 5 30 34 5 34 17 2 17 39 3 39 38 3 23 15 6 10 4 3 5 18 3 26 2 4 3 38 3 27 3 4 6 2 2 19 32 5 12 21 2 31 19 2 29 30 3 25 24 4 35 14 5 37 24 2 7 10 5 1 2 4 9 26 4 36 37 6 16 17 5 13...
output:
impossible
result:
ok
Test #26:
score: 0
Accepted
time: 2ms
memory: 10972kb
input:
40 32 9 265 9 1 377 1 30 203 30 26 554 26 35 434 35 11 397 11 6 300 6 36 218 36 17 352 17 19 312 19 39 417 39 4 51 4 22 167 22 12 79 12 24 78 24 18 100 18 14 266 14 37 63 37 34 92 34 32 327 40 36 474 10 17 589 25 22 133 20 35 374 15 18 547 8 34 334 23 8 218 27 25 591 28 22 129 21 23 325 31 20 306 29...
output:
32 9 1 30 26 35 11 6 36 17 19 39 4 22 12 24 18 14 37 34 40 10 25 20 15 8 23 27 28 21 31 29 2 38 5 3 13 16 7 33
result:
ok
Test #27:
score: 0
Accepted
time: 3ms
memory: 10992kb
input:
2000 904 1381 2 1381 1985 2 1985 220 2 220 1512 2 1512 44 2 44 1739 2 1739 584 2 584 633 2 633 1645 2 1645 207 2 207 1137 2 1137 455 2 455 348 2 348 1225 2 1225 267 2 267 1503 2 1503 437 2 437 502 2 502 1447 2 1447 654 2 654 898 2 898 1546 2 1546 1761 2 1761 253 2 253 496 2 496 256 2 256 563 2 563 1...
output:
impossible
result:
ok
Test #28:
score: 0
Accepted
time: 3ms
memory: 10984kb
input:
2000 1565 1877 10 1877 962 3 962 81 4 81 1782 7 1782 267 9 267 1979 6 1979 270 2 270 1685 2 1685 1920 8 1920 1032 10 1032 904 3 904 712 4 712 141 2 141 1440 8 1440 1739 3 1739 21 3 21 86 3 86 1497 10 1497 765 2 765 227 3 227 553 10 553 1821 7 1821 1384 3 1384 1041 9 1041 1196 9 1196 1600 4 1600 699 ...
output:
impossible
result:
ok
Test #29:
score: 0
Accepted
time: 3ms
memory: 11324kb
input:
2000 1779 220 18758 220 1051 55377 1051 933 84997 933 1862 15548 1862 604 15811 604 1503 30202 1503 1327 68213 1327 128 72237 128 1978 70598 1978 1311 1521 1311 842 97799 842 256 9544 256 967 24128 967 1822 57597 1822 91 4163 91 1158 34674 1158 731 15083 731 796 66660 796 1785 6454 1785 1773 27844 1...
output:
1779 220 1051 933 1862 604 1503 1327 128 1978 1311 842 256 967 1822 91 1158 731 796 1785 1773 1782 241 1275 1702 131 1678 1166 1055 70 300 913 151 703 1874 1230 53 542 851 1423 886 1747 1440 509 1167 383 1909 827 593 1541 870 1717 1959 15 500 1057 1340 1673 1222 847 1553 822 614 1409 1686 1016 1584 ...
result:
ok
Test #30:
score: 0
Accepted
time: 9ms
memory: 14528kb
input:
20000 17377 7462 43414 7462 6444 34846 6444 12502 46766 12502 3164 25321 3164 18850 38351 18850 5584 95722 5584 16784 26774 16784 19535 66565 19535 7483 50407 7483 89 654 89 9525 20741 9525 14911 64248 14911 18006 40663 18006 15076 29338 15076 5229 27545 5229 16316 90368 16316 14341 59818 14341 10 3...
output:
17377 7462 6444 12502 3164 18850 5584 16784 19535 7483 89 9525 14911 18006 15076 5229 16316 14341 10 16222 4523 17435 8403 13442 15509 7331 8624 12111 4373 14620 192 18849 9092 13895 11860 16492 660 15533 9187 6129 1980 19080 16874 19537 13844 8642 2236 1351 1205 9178 4419 4165 10795 1996 17505 5432...
result:
ok
Test #31:
score: 0
Accepted
time: 22ms
memory: 17744kb
input:
40000 3056 27800 95 27800 33216 6 33216 24544 49 24544 22475 108 22475 1922 55 1922 30971 75 30971 17451 36 17451 19432 99 19432 31293 17 31293 36775 45 36775 8440 17 8440 4453 90 4453 3547 100 3547 22126 59 22126 22573 21 22573 22629 69 22629 7739 70 7739 29150 64 29150 12713 53 12713 38751 60 3875...
output:
impossible
result:
ok
Test #32:
score: 0
Accepted
time: 61ms
memory: 34404kb
input:
100000 23966 66420 9 66420 63738 4 63738 54057 3 54057 90473 4 90473 44017 2 44017 22739 3 22739 67875 5 67875 93384 5 93384 78042 8 78042 89954 9 89954 90911 10 90911 34650 5 34650 13764 4 13764 13310 10 13310 49188 8 49188 95990 8 95990 73108 8 73108 58130 9 58130 19807 10 19807 28128 7 28128 5577...
output:
impossible
result:
ok
Test #33:
score: 0
Accepted
time: 69ms
memory: 34240kb
input:
100000 11175 115 48 115 90967 889 90967 94717 575 94717 47851 396 47851 17047 764 17047 39521 830 39521 85180 627 85180 83705 912 83705 53962 541 53962 57880 241 57880 22997 898 22997 45561 687 45561 72744 888 72744 69124 762 69124 12461 963 12461 7712 909 7712 96469 509 96469 3111 915 3111 49718 29...
output:
impossible
result:
ok
Test #34:
score: 0
Accepted
time: 58ms
memory: 34164kb
input:
100000 32289 1170 74 1170 30730 558 30730 22516 639 22516 28701 726 28701 70928 513 70928 28004 335 28004 12342 425 12342 51343 23 51343 27759 810 27759 53888 496 53888 15343 247 15343 11069 196 11069 27001 152 27001 92151 637 92151 94872 933 94872 10759 235 10759 33879 1147 33879 24228 510 24228 76...
output:
impossible
result:
ok
Test #35:
score: 0
Accepted
time: 85ms
memory: 34152kb
input:
100000 38401 61337 5600 61337 3805 10303 3805 56171 1553 56171 94556 8315 94556 83394 5128 83394 77189 10517 77189 4883 10478 4883 79778 2396 79778 19819 12319 19819 27727 9656 27727 22382 1943 22382 33237 5638 33237 86555 4540 86555 55488 6084 55488 39372 1581 39372 50569 263 50569 64870 10718 6487...
output:
61337 3805 56171 94556 83394 77189 4883 79778 19819 27727 22382 33237 86555 55488 39372 50569 64870 84132 98196 44225 87560 80994 53825 7871 21591 30366 46162 11673 65713 58188 75859 82769 46352 73494 31933 7602 63104 71462 42605 2397 92638 36724 38621 72606 60653 57792 76183 58535 12994 52557 56160...
result:
ok
Test #36:
score: 0
Accepted
time: 47ms
memory: 34408kb
input:
100000 1036 5630 217740837 5630 59292 597515142 59292 30882 90655846 30882 88879 548429812 88879 81858 491838541 81858 23657 854286872 23657 6686 187045899 6686 37208 974328050 37208 74491 79601835 74491 98680 374043292 98680 5011 121034066 5011 62878 949754673 62878 57001 219956938 57001 70435 7936...
output:
1036 5630 59292 30882 88879 81858 23657 6686 37208 74491 98680 5011 62878 57001 70435 27315 79931 98006 25536 74525 73540 36892 26188 18517 81767 31649 31835 33314 81839 71975 60599 97033 2388 54518 81285 49816 85728 1987 24373 2145 49649 68016 27274 84900 19050 54453 2265 37628 66157 54830 77628 40...
result:
ok
Test #37:
score: 0
Accepted
time: 3ms
memory: 10584kb
input:
15 5 13 1000000000 13 7 999999996 7 2 999999996 2 9 999999991 9 8 999999998 8 12 999999993 12 10 999999993 10 15 999999996 15 3 1000000000 3 5 1000000000 4 9 999999993 11 7 999999991 1 5 999999992 6 3 999999992 14 10 999999992
output:
13 7 2 9 8 12 10 15 3 5 4 11 1 6 14
result:
ok
Test #38:
score: 0
Accepted
time: 68ms
memory: 34400kb
input:
100000 42275 23968 999999933 23968 82939 999999902 82939 76209 999999924 76209 27948 999999933 27948 32074 999999931 32074 34768 999999907 34768 58452 999999924 58452 76979 999999918 76979 80899 999999905 80899 83273 999999994 83273 53239 999999973 53239 12765 999999927 12765 68457 999999967 68457 9...
output:
impossible
result:
ok
Test #39:
score: 0
Accepted
time: 0ms
memory: 11556kb
input:
6 2 3 2 1 2 2 3 1 3 1 4 3 1 5 4 1 6 5
output:
3 2 1 4 5 6
result:
ok
Test #40:
score: 0
Accepted
time: 0ms
memory: 10584kb
input:
6 2 3 2 1 2 3 3 1 2 1 4 3 1 5 4 1 6 5
output:
2 1 3 4 5 6
result:
ok
Test #41:
score: 0
Accepted
time: 48ms
memory: 24364kb
input:
100000 2 3 2 1 2 2 3 1 3 1 4 3 1 5 4 1 6 5 1 7 6 1 8 7 1 9 8 1 10 9 1 11 10 1 12 11 1 13 12 1 14 13 1 15 14 1 16 15 1 17 16 1 18 17 1 19 18 1 20 19 1 21 20 1 22 21 1 23 22 1 24 23 1 25 24 1 26 25 1 27 26 1 28 27 1 29 28 1 30 29 1 31 30 1 32 31 1 33 32 1 34 33 1 35 34 1 36 35 1 37 36 1 38 37 1 39 38 ...
output:
3 2 1 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #42:
score: 0
Accepted
time: 81ms
memory: 24384kb
input:
100000 2 3 2 1 2 3 3 1 2 1 4 3 1 5 4 1 6 5 1 7 6 1 8 7 1 9 8 1 10 9 1 11 10 1 12 11 1 13 12 1 14 13 1 15 14 1 16 15 1 17 16 1 18 17 1 19 18 1 20 19 1 21 20 1 22 21 1 23 22 1 24 23 1 25 24 1 26 25 1 27 26 1 28 27 1 29 28 1 30 29 1 31 30 1 32 31 1 33 32 1 34 33 1 35 34 1 36 35 1 37 36 1 38 37 1 39 38 ...
output:
2 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...
result:
ok
Test #43:
score: 0
Accepted
time: 31ms
memory: 29772kb
input:
100000 2 3 2 3 4 2 4 5 2 5 6 2 6 7 2 7 8 2 8 9 2 9 10 2 10 11 2 11 12 2 12 13 2 13 14 2 14 15 2 15 16 2 16 17 2 17 18 2 18 19 2 19 20 2 20 21 2 21 22 2 22 23 2 23 24 2 24 25 2 25 26 2 26 27 2 27 28 2 28 29 2 29 30 2 30 31 2 31 32 2 32 33 2 33 34 2 34 35 2 35 36 2 36 37 2 37 38 2 38 39 2 39 40 2 40 4...
output:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ...
result:
ok
Test #44:
score: 0
Accepted
time: 37ms
memory: 29944kb
input:
100000 2 3 2 3 4 2 4 5 2 5 6 2 6 7 2 7 8 2 8 9 2 9 10 2 10 11 2 11 12 2 12 13 2 13 14 2 14 15 2 15 16 2 16 17 2 17 18 2 18 19 2 19 20 2 20 21 2 21 22 2 22 23 2 23 24 2 24 25 2 25 26 2 26 27 2 27 28 2 28 29 2 29 30 2 30 31 2 31 32 2 32 33 2 33 34 2 34 35 2 35 36 2 36 37 2 37 38 2 38 39 2 39 40 2 40 4...
output:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ...
result:
ok
Test #45:
score: 0
Accepted
time: 33ms
memory: 34424kb
input:
100000 2 3 2 3 4 2 4 5 2 5 6 2 6 7 2 7 8 2 8 9 2 9 10 2 10 11 2 11 12 2 12 13 2 13 14 2 14 15 2 15 16 2 16 17 2 17 18 2 18 19 2 19 20 2 20 21 2 21 22 2 22 23 2 23 24 2 24 25 2 25 26 2 26 27 2 27 28 2 28 29 2 29 30 2 30 31 2 31 32 2 32 33 2 33 34 2 34 35 2 35 36 2 36 37 2 37 38 2 38 39 2 39 40 2 40 4...
output:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ...
result:
ok
Test #46:
score: 0
Accepted
time: 37ms
memory: 34236kb
input:
100000 2 3 2 3 4 2 4 5 2 5 6 2 6 7 2 7 8 2 8 9 2 9 10 2 10 11 2 11 12 2 12 13 2 13 14 2 14 15 2 15 16 2 16 17 2 17 18 2 18 19 2 19 20 2 20 21 2 21 22 2 22 23 2 23 24 2 24 25 2 25 26 2 26 27 2 27 28 2 28 29 2 29 30 2 30 31 2 31 32 2 32 33 2 33 34 2 34 35 2 35 36 2 36 37 2 37 38 2 38 39 2 39 40 2 40 4...
output:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 ...
result:
ok