QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#105631 | #6396. Puzzle: Kusabi | woyouxiangbaile# | AC ✓ | 39ms | 31604kb | C++14 | 4.1kb | 2023-05-14 16:39:01 | 2023-05-14 16:39:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, d, u) for(int i = d; i <= u; ++i)
#define dep(i, u, d) for(int i = u; i >= d; --i)
#define cep(n) while(n--)
#define gep(i, a) for(int i = firs[a]; i; i = neig[i])
int ured() {
int re = 0;
char ch;
do {
ch = getchar();
} while('9' < ch || ch < '0');
do {
re = re * 10 + (ch ^ '0');
} while('0' <= (ch = getchar()) && ch <= '9');
return re;
}
char cred() {
char ch;
do {
ch = getchar();
} while(('Z' < ch || ch < 'A') && ch != '-');
return ch;
}
void uwit(int da) {
int ch[21], cn = 0;
do {
ch[++cn] = da - da / 10 * 10;
} while(da /= 10);
do {
putchar('0' ^ ch[cn]);
} while(--cn);
}
const int _maxn = 100011;
int n, a, b, firs[_maxn], neig[_maxn << 1], arri[_maxn << 1], s[_maxn], dpoa[_maxn], dpob[_maxn], dept[_maxn], rans[_maxn];
char c;
bool pdif, dpod[_maxn];
void dfs1(int at, int fa) {
dept[at] = dept[fa] + 1;
set<int> st;
map<int, int> po;
if(s[at] == 1) {
st . insert(dept[at]), po[dept[at]] = at;
}
gep(i, at) {
if(arri[i] != fa) {
dfs1(arri[i], at);
if(dpoa[arri[i]]) {
if(st . count(dept[dpoa[arri[i]]])) {
rans[po[dept[dpoa[arri[i]]]]] = dpoa[arri[i]], rans[dpoa[arri[i]]] = po[dept[dpoa[arri[i]]]], st . erase(dept[dpoa[arri[i]]]);
} else {
st . insert(dept[dpoa[arri[i]]]), po[dept[dpoa[arri[i]]]] = dpoa[arri[i]];
}
}
}
}
if(st . size() > 1) {
pdif = 1;
} else if(st . size()) {
dpoa[at] = po[*st . begin()];
}
}
struct node {
int da, at;
node() {}
node(int fi, int se) : da(fi), at(se) {}
};
bool operator<(node le, node ri) {
return le . da == ri . da ? le . at < ri . at : le . da < ri . da;
}
std :: set<node> sets;
std :: set<node> :: iterator regi;
void dfs2(int at, int fa) {
vector<int> sa, sb;
if(s[at] == 2) {
sa . push_back(at);
} else if(s[at] == 3) {
sb . push_back(at);
}
gep(i, at) {
if(arri[i] != fa) {
dfs2(arri[i], at);
if(s[dpob[arri[i]]] == 2) {
sa . push_back(dpob[arri[i]]);
} else if(s[dpob[arri[i]]] == 3) {
sb . push_back(dpob[arri[i]]);
}
}
}
if(sa . size() == sb . size() + 1) {
sets . clear();
for(int i : sb) {
sets . insert(node(dept[i], i));
}
sort(sa . begin(), sa . end(), [](int le, int ri) {
return dept[le] > dept[ri];
});
for(int i : sa) {
if((regi = sets . upper_bound(node(dept[i], n))) == sets . end()) {
if(dpob[at]) {
pdif = 1;
break;
} else {
dpob[at] = i;
}
} else {
rans[i] = regi -> at, rans[regi -> at] = i, sets . erase(regi);
}
}
} else if(sa . size() + 1 == sb . size()) {
sets . clear();
for(int i : sa) {
sets . insert(node(dept[i], i));
}
sort(sb . begin(), sb . end(), [](int le, int ri) {
return dept[le] < dept[ri];
});
for(int i : sb) {
if((regi = sets . lower_bound(node(dept[i], 1))) == sets . begin()) {
if(dpob[at]) {
pdif = 1;
break;
} else {
dpob[at] = i;
}
} else {
rans[i] = prev(regi) -> at, rans[prev(regi) -> at] = i, sets . erase(prev(regi));
}
}
} else if(sa . size() == sb . size()) {
if(sa . size()) {
sort(sa . begin(), sa . end(), [](int le, int ri) {
return dept[le] < dept[ri];
}), sort(sb . begin(), sb . end(), [](int le, int ri) {
return dept[le] < dept[ri];
});
rep(i, 0, sa . size() - 1) {
if(dept[sa[i]] < dept[sb[i]]) {
rans[sa[i]] = sb[i], rans[sb[i]] = sa[i];
} else {
pdif = 1;
return;
}
}
}
} else {
pdif = 1;
}
}
int main() {
n = ured();
rep(i, 1, n - 1) {
a = ured(), b = ured(), neig[i << 1] = firs[a], firs[a] = i << 1, arri[i << 1] = b;
neig[i << 1 | 1] = firs[b], firs[b] = i << 1 | 1, arri[i << 1 | 1] = a;
if((c = cred()) == 'T') {
s[a] = 1;
} else if(c == 'D') {
s[a] = 2;
} else if(c == 'C') {
s[a] = 3;
}
}
dfs1(1, 0);
if(pdif || dpoa[1]) {
puts("NO");
return 0;
}
dfs2(1, 0);
if(pdif) {
puts("NO");
return 0;
}
puts("YES");
rep(i, 1, n) {
if(rans[i] && rans[i] < i) {
uwit(rans[i]), putchar(' '), uwit(i), putchar('\n');
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5432kb
input:
8 2 1 - 3 1 - 4 2 Tong 5 2 Tong 6 3 Duan 7 3 - 8 7 Chang
output:
YES 4 5 6 8
result:
ok Correct.
Test #2:
score: 0
Accepted
time: 2ms
memory: 5376kb
input:
10 2 1 Duan 3 2 Duan 4 2 - 5 4 Chang 6 2 Chang 7 1 Duan 8 6 Tong 9 6 Tong 10 3 Chang
output:
YES 2 6 5 7 8 9 3 10
result:
ok Correct.
Test #3:
score: 0
Accepted
time: 2ms
memory: 3368kb
input:
2 2 1 Tong
output:
NO
result:
ok Correct.
Test #4:
score: 0
Accepted
time: 26ms
memory: 7216kb
input:
100000 2 1 Duan 3 1 Duan 4 3 - 5 4 Duan 6 3 - 7 4 Duan 8 4 - 9 8 - 10 7 Duan 11 9 - 12 7 Duan 13 7 Duan 14 8 Duan 15 13 - 16 10 Duan 17 11 Duan 18 12 - 19 1 Duan 20 5 Duan 21 4 Duan 22 14 Duan 23 16 - 24 22 Duan 25 16 Duan 26 13 - 27 13 - 28 17 - 29 5 Duan 30 22 - 31 23 - 32 9 Duan 33 5 - 34 30 Duan...
output:
YES 86 106 93 164 39 181 126 204 197 228 70 265 237 305 217 323 253 339 81 393 435 447 159 563 320 591 418 612 376 674 20 693 570 730 550 813 863 867 969 973 56 1008 1005 1035 1018 1096 575 1108 1056 1124 893 1164 186 1184 473 1196 478 1259 1168 1261 497 1271 432 1348 955 1373 161 1402 1081 1464 306...
result:
ok Correct.
Test #5:
score: 0
Accepted
time: 15ms
memory: 7232kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 4 - 7 6 - 8 7 - 9 5 - 10 9 - 11 10 - 12 6 - 13 12 - 14 11 - 15 9 - 16 14 - 17 16 - 18 10 - 19 15 - 20 13 - 21 20 - 22 17 - 23 22 - 24 22 Duan 25 11 - 26 12 - 27 20 - 28 18 - 29 28 - 30 16 - 31 28 - 32 30 - 33 31 - 34 28 - 35 34 - 36 35 - 37 22 - 38 34 - 39 38 - 40 35...
output:
YES 120 126 85 128 162 226 138 256 240 269 81 340 420 431 345 519 382 614 563 656 459 657 112 685 24 768 168 823 151 874 548 899 407 931 627 968 333 1088 402 1103 1152 1222 1049 1256 1205 1326 1327 1377 854 1429 206 1489 773 1535 1130 1550 1192 1606 814 1700 744 1703 351 1721 869 1756 1559 1764 1360...
result:
ok Correct.
Test #6:
score: 0
Accepted
time: 39ms
memory: 7332kb
input:
100000 2 1 - 3 2 - 4 3 Duan 5 4 Chang 6 5 Duan 7 6 Chang 8 7 Duan 9 8 Chang 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 12 Duan 15 14 Chang 16 15 Tong 17 15 Tong 18 17 Duan 19 18 Duan 20 19 Chang 21 18 Duan 22 21 Duan 23 18 Chang 24 21 - 25 24 Duan 26 25 Chang 27 26 Duan 28 27 Chang 29 26 Duan 3...
output:
YES 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 18 23 25 26 27 28 21 33 22 34 35 36 31 37 32 39 29 41 40 42 38 43 30 45 46 48 52 53 56 57 54 60 58 61 49 63 55 65 50 66 64 68 67 69 59 73 70 78 71 79 76 82 83 85 84 86 77 87 75 90 74 91 80 93 89 94 97 100 98 101 92 104 95 105 96 112 111 113 99 114 109 11...
result:
ok Correct.
Test #7:
score: 0
Accepted
time: 34ms
memory: 7440kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 Duan 11 10 - 12 11 Chang 13 12 Duan 14 13 Chang 15 14 - 16 15 - 17 16 Duan 18 17 Chang 19 17 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 Duan 27 26 - 28 27 Duan 29 28 - 30 29 Chang 31 28 - 32 31 Chang 33 32 - 34 32 - 35 34 - 36 ...
output:
YES 10 12 13 14 17 18 26 30 28 32 38 47 51 55 59 70 74 82 81 85 105 107 80 116 103 117 126 131 130 134 137 141 138 144 139 145 147 156 133 157 151 160 149 165 168 172 163 181 174 185 179 188 173 189 169 199 197 216 207 218 224 230 211 231 244 247 233 250 223 255 260 262 253 265 273 275 279 286 287 2...
result:
ok Correct.
Test #8:
score: 0
Accepted
time: 24ms
memory: 7500kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 - 10 9 Chang 11 10 - 12 11 Duan 13 12 Chang 14 13 - 15 14 Duan 16 15 Chang 17 16 - 18 17 - 19 18 Duan 20 19 - 21 20 - 22 21 - 23 22 Chang 24 23 - 25 24 Duan 26 25 - 27 26 Chang 28 27 - 29 28 - 30 29 - 31 30 Duan 32 31 - 33 32 - 34 33 - 35 34 - ...
output:
YES 6 10 12 13 15 16 19 23 25 27 31 36 39 44 46 47 52 53 59 62 65 66 68 69 71 74 79 81 82 87 83 92 93 94 98 100 102 105 108 110 112 117 118 120 122 130 132 133 134 142 144 148 155 161 165 168 169 170 171 173 175 178 183 187 194 199 203 205 202 207 212 214 215 217 223 224 221 225 226 232 227 237 242 ...
result:
ok Correct.
Test #9:
score: 0
Accepted
time: 23ms
memory: 7832kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 Chang 10 9 - 11 10 Duan 12 11 - 13 12 Chang 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 Duan 19 18 - 20 19 Chang 21 20 Duan 22 21 Chang 23 22 - 24 23 Duan 25 24 Chang 26 25 Duan 27 26 - 28 27 - 29 28 Chang 30 29 Duan 31 30 Chang 32 31 - 33 32 ...
output:
YES 6 9 11 13 14 16 18 20 21 22 24 25 26 29 30 31 33 34 35 38 39 40 42 44 47 49 51 52 53 54 55 56 57 58 59 60 61 62 63 64 66 70 74 77 78 80 81 83 84 86 87 92 93 94 96 98 100 102 107 108 109 110 114 115 116 117 118 121 124 125 126 130 131 134 137 138 144 146 149 150 147 152 155 156 158 162 164 165 16...
result:
ok Correct.
Test #10:
score: 0
Accepted
time: 7ms
memory: 8244kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 - 11 10 - 12 11 - 13 12 - 14 13 - 15 14 - 16 15 - 17 16 - 18 17 - 19 18 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 - 27 26 - 28 27 - 29 28 - 30 29 - 31 30 - 32 31 - 33 32 - 34 33 - 35 34 - 36 35 - 37 36 - 38 37 - 39 38 - 40 39 ...
output:
YES 46 187 379 560 617 664 1104 1599 1692 1891 2060 2120 2231 2560 3050 3072 3156 3161 3406 3700 3934 3939 4116 4338 4326 4581 4758 4774 4915 4986 5196 5281 5384 5513 5677 6435 6536 6606 6570 6738 7012 7037 7170 7289 7658 7686 7894 7922 8110 8465 8862 9157 9716 9769 9829 10261 11025 11281 11802 1200...
result:
ok Correct.
Test #11:
score: 0
Accepted
time: 18ms
memory: 7204kb
input:
100000 2 1 - 3 1 - 4 2 - 5 1 - 6 1 - 7 2 Duan 8 4 - 9 1 - 10 1 - 11 2 - 12 2 - 13 2 - 14 6 - 15 1 - 16 6 - 17 1 - 18 5 - 19 1 - 20 1 - 21 2 - 22 8 - 23 6 - 24 1 - 25 4 Duan 26 1 - 27 10 - 28 1 - 29 8 - 30 5 - 31 7 - 32 2 - 33 3 - 34 12 - 35 3 - 36 1 - 37 12 - 38 8 - 39 8 - 40 1 - 41 4 - 42 16 - 43 8...
output:
YES 1830 1992 743 2652 1279 2802 1097 3269 140 3539 932 3570 288 3754 1711 4308 563 4697 3024 4873 274 5008 956 5107 301 5367 1164 5426 2302 5427 947 5523 2403 5535 461 5650 3381 6001 1797 6006 3985 6194 6090 6237 898 6313 209 6399 5160 6442 3832 6478 2795 6538 989 6568 432 6592 2417 6619 3234 6685 ...
result:
ok Correct.
Test #12:
score: 0
Accepted
time: 12ms
memory: 7204kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 3 - 11 1 - 12 2 - 13 2 - 14 2 - 15 1 - 16 2 - 17 2 - 18 1 - 19 1 - 20 1 - 21 2 - 22 1 - 23 2 - 24 2 - 25 1 - 26 1 - 27 4 - 28 1 - 29 2 - 30 3 - 31 1 - 32 10 - 33 6 - 34 4 - 35 1 - 36 2 Duan 37 1 - 38 4 - 39 10 - 40 1 - 41 1 - 42 3 - 43 6 - 44...
output:
YES 350 2306 1182 2525 677 4201 4204 6020 1751 6314 5016 6707 2310 7601 3663 7603 7471 7705 4411 7761 236 7770 5728 7900 6079 8567 8230 8582 1870 8659 8253 9133 2162 9312 3379 9510 1744 9703 8168 9754 7087 9814 7725 9922 9520 10084 9397 10191 10068 10242 1019 10268 547 10309 4763 10387 8709 10406 10...
result:
ok Correct.
Test #13:
score: 0
Accepted
time: 27ms
memory: 7368kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 - 8 1 Duan 9 1 Duan 10 1 - 11 1 Duan 12 1 - 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 2 - 19 1 Duan 20 1 Duan 21 2 - 22 2 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 2 Duan 28 1 Duan 29 2 Duan 30 1 Duan 31 2 Duan 32 1 - 33 1 Duan...
output:
YES 424 904 11 1036 1098 1717 1795 2181 1216 2815 2010 2824 1231 2836 2213 2874 2103 2877 454 2940 2365 2994 1937 3122 2517 3253 2474 3297 3065 3340 2303 3368 3017 3469 2687 3558 3541 3626 2475 3776 3746 3808 3560 3816 3172 3921 4041 4049 69 4125 4042 4183 4236 4251 3876 4267 3900 4354 3450 4389 368...
result:
ok Correct.
Test #14:
score: 0
Accepted
time: 17ms
memory: 7244kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 - 13 1 Duan 14 1 - 15 1 - 16 1 - 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 - 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 Duan 30 1 - 31 1 - 32 2 Duan 33 1 - 34 1 - 35 1 Duan 36 1 - 37 1 - 38 1 - 39 1 - 40 1 - 41 1 - 42 1 - 43...
output:
YES 1146 1282 1048 1390 844 1482 1139 1581 894 1630 13 1769 1666 1853 1958 1970 856 1981 217 2112 2136 2170 1779 2173 1741 2174 1623 2199 1566 2328 1054 2333 2046 2371 1772 2415 2264 2456 2426 2531 1758 2534 2192 2538 2153 2555 2430 2583 2432 2589 2515 2651 1392 2655 2365 2684 1872 2715 2262 2754 26...
result:
ok Correct.
Test #15:
score: 0
Accepted
time: 7ms
memory: 7204kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 Duan 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 - 13 1 - 14 1 - 15 1 - 16 1 - 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 - 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 - 30 1 - 31 1 - 32 1 - 33 1 Duan 34 1 - 35 1 - 36 1 - 37 1 - 38 1 - 39 1 - 40 1 - 41 1 - 42 1 - 43 1 ...
output:
YES 587 688 647 717 809 825 411 842 888 911 813 1012 946 1055 518 1073 931 1079 1124 1125 1007 1132 1088 1197 1165 1219 784 1279 1240 1356 1367 1385 1374 1395 1216 1420 1405 1431 926 1438 1404 1457 1558 1594 1399 1610 1630 1652 1560 1656 1508 1664 1672 1690 1649 1716 1563 1722 1282 1744 1595 1751 17...
result:
ok Correct.
Test #16:
score: 0
Accepted
time: 25ms
memory: 7284kb
input:
100000 2 1 Duan 3 1 Duan 4 1 - 5 1 Duan 6 1 - 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 - 12 1 - 13 1 - 14 1 Duan 15 1 Duan 16 1 Duan 17 1 - 18 1 Duan 19 1 Duan 20 1 Duan 21 1 - 22 1 - 23 1 Duan 24 1 Duan 25 1 Duan 26 1 - 27 1 - 28 1 Duan 29 1 Duan 30 1 - 31 1 Duan 32 1 Duan 33 1 - 34 1 Duan 35 1 - ...
output:
YES 240 274 282 293 294 322 344 369 376 384 391 407 413 419 431 435 438 439 442 444 377 464 472 474 476 489 490 494 500 512 513 519 523 526 527 529 534 535 539 547 549 551 553 554 557 558 564 569 563 573 570 577 574 587 594 600 602 603 604 608 543 612 609 621 623 627 624 630 632 642 644 646 647 648 ...
result:
ok Correct.
Test #17:
score: 0
Accepted
time: 16ms
memory: 7308kb
input:
100000 2 1 - 3 1 - 4 2 - 5 2 - 6 2 Duan 7 3 - 8 1 - 9 1 - 10 6 - 11 3 - 12 2 - 13 7 - 14 1 - 15 9 - 16 11 - 17 13 - 18 9 - 19 16 - 20 19 - 21 8 - 22 5 - 23 14 - 24 21 - 25 21 - 26 16 - 27 5 - 28 5 - 29 19 - 30 8 - 31 24 - 32 30 - 33 12 Duan 34 9 - 35 12 Duan 36 6 - 37 15 - 38 26 - 39 29 - 40 13 - 41...
output:
NO
result:
ok Correct.
Test #18:
score: 0
Accepted
time: 21ms
memory: 7228kb
input:
100000 2 1 Duan 3 2 Duan 4 3 - 5 3 Duan 6 4 - 7 4 Duan 8 3 Duan 9 2 - 10 4 Duan 11 8 Duan 12 6 - 13 3 Duan 14 6 Duan 15 7 Duan 16 6 Duan 17 14 Tong 18 7 - 19 16 Duan 20 14 Duan 21 12 Duan 22 20 Duan 23 14 Duan 24 19 - 25 2 Duan 26 22 - 27 24 Duan 28 8 Duan 29 4 Duan 30 23 Duan 31 24 Duan 32 23 Duan ...
output:
NO
result:
ok Correct.
Test #19:
score: 0
Accepted
time: 12ms
memory: 7228kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 - 7 4 - 8 7 - 9 8 - 10 9 - 11 10 Duan 12 9 - 13 12 - 14 12 - 15 10 - 16 8 - 17 13 - 18 10 - 19 14 - 20 13 - 21 19 - 22 19 Duan 23 11 - 24 23 Duan 25 23 - 26 5 - 27 22 - 28 22 Duan 29 17 - 30 29 - 31 29 - 32 17 - 33 27 - 34 33 Duan 35 31 - 36 24 - 37 34 - 38 37 - 39...
output:
NO
result:
ok Correct.
Test #20:
score: 0
Accepted
time: 9ms
memory: 7156kb
input:
100000 2 1 Duan 3 2 Chang 4 3 - 5 4 - 6 5 - 7 6 Duan 8 7 - 9 8 Chang 10 9 Duan 11 10 Chang 12 11 - 13 12 Duan 14 13 Chang 15 13 - 16 15 - 17 15 - 18 15 Duan 19 18 - 20 19 Duan 21 19 Chang 22 20 - 23 22 - 24 21 Duan 25 23 - 26 22 - 27 25 Chang 28 26 - 29 28 Duan 30 24 Chang 31 28 - 32 23 - 33 28 - 34...
output:
NO
result:
ok Correct.
Test #21:
score: 0
Accepted
time: 17ms
memory: 7368kb
input:
100000 2 1 Duan 3 2 Chang 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 - 9 8 Chang 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 12 - 15 14 - 16 15 Duan 17 16 Chang 18 17 - 19 17 Duan 20 19 - 21 19 Chang 22 21 - 23 21 Duan 24 23 Duan 25 24 Chang 26 24 Chang 27 24 Duan 28 27 - 29 28 Chang 30 28 Duan 31 30 - 32 3...
output:
NO
result:
ok Correct.
Test #22:
score: 0
Accepted
time: 10ms
memory: 7016kb
input:
100000 2 1 Duan 3 2 Chang 4 3 Duan 5 4 - 6 5 Chang 7 6 - 8 7 Duan 9 8 - 10 9 Chang 11 10 Duan 12 11 Chang 13 12 - 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 Duan 19 18 - 20 19 - 21 20 - 22 21 Chang 23 22 - 24 23 Duan 25 24 Chang 26 25 - 27 26 Duan 28 27 - 29 28 Chang 30 28 Duan 31 30 - 32 31 Chang...
output:
NO
result:
ok Correct.
Test #23:
score: 0
Accepted
time: 10ms
memory: 7860kb
input:
100000 2 1 Duan 3 2 - 4 3 - 5 4 - 6 5 - 7 6 - 8 7 - 9 8 - 10 9 - 11 10 - 12 11 Chang 13 12 Duan 14 13 - 15 14 - 16 15 Chang 17 16 Duan 18 17 Chang 19 18 - 20 19 - 21 20 - 22 21 - 23 22 - 24 23 - 25 24 - 26 25 Duan 27 26 - 28 27 - 29 28 - 30 29 - 31 30 - 32 31 - 33 32 - 34 33 Chang 35 34 - 36 35 - 37...
output:
NO
result:
ok Correct.
Test #24:
score: 0
Accepted
time: 5ms
memory: 8544kb
input:
100000 2 1 - 3 2 - 4 3 - 5 4 - 6 5 Duan 7 6 - 8 7 Chang 9 8 - 10 9 - 11 10 - 12 11 - 13 12 - 14 13 Duan 15 14 - 16 15 Chang 17 16 - 18 17 - 19 18 - 20 19 Duan 21 20 - 22 21 - 23 22 - 24 23 Chang 25 24 - 26 25 Duan 27 26 Chang 28 27 Duan 29 28 - 30 29 - 31 30 - 32 31 Chang 33 32 Duan 34 33 - 35 34 - ...
output:
NO
result:
ok Correct.
Test #25:
score: 0
Accepted
time: 9ms
memory: 7456kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 - 6 3 - 7 2 - 8 2 - 9 4 - 10 1 - 11 2 - 12 3 Duan 13 2 - 14 4 - 15 3 - 16 3 - 17 2 - 18 2 - 19 1 - 20 7 Duan 21 1 - 22 15 - 23 6 - 24 1 - 25 8 - 26 11 - 27 5 - 28 16 - 29 17 - 30 16 - 31 3 - 32 7 - 33 3 Duan 34 7 Duan 35 3 - 36 8 - 37 6 - 38 16 - 39 3 - 40 3 - 41 11 -...
output:
NO
result:
ok Correct.
Test #26:
score: 0
Accepted
time: 13ms
memory: 7228kb
input:
100000 2 1 - 3 1 - 4 1 - 5 1 - 6 1 - 7 1 Duan 8 1 - 9 1 - 10 1 - 11 3 - 12 2 - 13 1 - 14 1 - 15 1 - 16 2 - 17 1 Duan 18 3 - 19 1 - 20 1 Duan 21 8 - 22 2 - 23 3 - 24 3 Duan 25 1 - 26 1 - 27 1 - 28 1 - 29 4 - 30 1 - 31 3 - 32 3 - 33 3 - 34 2 - 35 1 - 36 1 Duan 37 1 - 38 3 - 39 2 - 40 4 - 41 2 Duan 42 ...
output:
NO
result:
ok Correct.
Test #27:
score: 0
Accepted
time: 22ms
memory: 7240kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 Duan 12 1 Duan 13 1 Duan 14 2 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 2 Duan 19 1 Duan 20 1 - 21 1 Duan 22 1 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 2 Duan 28 1 Duan 29 1 Duan 30 1 - 31 1 Duan 32 1 Du...
output:
NO
result:
ok Correct.
Test #28:
score: 0
Accepted
time: 13ms
memory: 7244kb
input:
100000 2 1 - 3 1 Duan 4 1 - 5 1 - 6 1 - 7 1 Duan 8 1 - 9 1 Duan 10 1 - 11 1 Duan 12 1 Duan 13 1 Duan 14 1 Duan 15 1 Duan 16 1 - 17 1 Duan 18 1 Duan 19 1 Duan 20 1 Duan 21 1 - 22 1 - 23 1 Duan 24 1 - 25 1 Duan 26 1 Duan 27 1 Duan 28 1 Duan 29 1 Duan 30 1 Duan 31 1 Duan 32 1 - 33 1 - 34 1 Duan 35 1 Du...
output:
NO
result:
ok Correct.
Test #29:
score: 0
Accepted
time: 18ms
memory: 7124kb
input:
100000 2 1 Duan 3 1 Duan 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 - 9 1 Duan 10 1 Duan 11 1 Duan 12 1 - 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 1 Duan 19 1 Duan 20 1 - 21 1 - 22 1 Duan 23 1 - 24 1 Duan 25 1 Duan 26 1 Duan 27 1 Duan 28 1 Duan 29 1 Duan 30 1 Duan 31 1 Duan 32 1 Duan 33 1 -...
output:
NO
result:
ok Correct.
Test #30:
score: 0
Accepted
time: 14ms
memory: 7224kb
input:
100000 2 1 Duan 3 1 - 4 1 Duan 5 1 Duan 6 1 Duan 7 1 Duan 8 1 Duan 9 1 Duan 10 1 Duan 11 1 Duan 12 1 Duan 13 1 Duan 14 1 Duan 15 1 Duan 16 1 Duan 17 1 Duan 18 1 Duan 19 1 - 20 1 Duan 21 1 Duan 22 1 Duan 23 1 Duan 24 1 Duan 25 1 Duan 26 1 Duan 27 1 Duan 28 1 - 29 1 Duan 30 1 Duan 31 1 Duan 32 1 - 33 ...
output:
NO
result:
ok Correct.
Test #31:
score: 0
Accepted
time: 34ms
memory: 31604kb
input:
100000 2 1 Duan 3 2 - 4 3 Chang 5 4 - 6 5 Duan 7 6 Chang 8 7 - 9 8 - 10 9 Duan 11 10 Chang 12 11 Duan 13 12 Chang 14 13 Duan 15 14 Chang 16 15 - 17 16 - 18 17 - 19 18 Duan 20 19 - 21 20 - 22 21 Chang 23 22 Duan 24 23 Chang 25 24 - 26 25 Duan 27 26 Chang 28 27 Duan 29 28 - 30 29 Chang 31 30 Duan 32 3...
output:
YES 2 4 6 7 10 11 12 13 14 15 19 22 23 24 26 27 28 30 31 33 34 35 36 37 38 39 41 42 43 44 48 49 50 51 53 54 55 56 57 59 60 61 63 64 67 68 69 70 71 73 74 75 76 77 78 79 80 81 83 84 85 87 88 89 90 91 93 94 95 96 98 100 101 105 107 109 110 111 112 114 115 117 118 120 121 122 123 124 125 126 127 128 131...
result:
ok Correct.
Test #32:
score: 0
Accepted
time: 9ms
memory: 7284kb
input:
100000 2 1 Duan 3 1 - 4 1 - 5 1 - 6 1 - 7 1 - 8 1 - 9 1 - 10 1 - 11 1 - 12 1 Tong 13 1 - 14 1 - 15 1 - 16 1 Tong 17 1 - 18 1 - 19 1 - 20 1 - 21 1 - 22 1 Tong 23 1 - 24 1 - 25 1 - 26 1 - 27 1 - 28 1 - 29 1 - 30 1 - 31 1 - 32 1 - 33 1 - 34 1 - 35 1 - 36 1 - 37 1 - 38 1 Tong 39 1 - 40 1 - 41 1 - 42 1 -...
output:
YES 12 16 22 38 43 45 50 58 61 62 75 83 96 102 103 107 120 122 124 127 164 172 195 201 203 208 221 233 238 242 251 253 256 257 261 265 270 271 278 285 286 287 300 301 303 317 322 328 330 345 351 378 380 393 394 397 403 405 414 415 422 425 442 444 448 456 460 461 463 484 486 504 510 514 518 522 530 5...
result:
ok Correct.
Test #33:
score: 0
Accepted
time: 12ms
memory: 7016kb
input:
93284 2 1 - 3 1 Duan 4 2 - 5 4 - 6 2 - 7 4 Duan 8 1 - 9 4 - 10 4 Duan 11 6 - 12 7 - 13 6 - 14 1 Duan 15 4 - 16 9 - 17 12 - 18 15 - 19 6 Duan 20 1 - 21 15 - 22 2 - 23 5 Duan 24 7 - 25 22 - 26 13 - 27 12 - 28 6 - 29 27 Duan 30 7 Duan 31 9 - 32 14 - 33 3 - 34 21 - 35 18 - 36 35 - 37 7 - 38 17 Duan 39 2...
output:
YES 101 211 310 313 234 494 745 897 72 916 662 942 243 1078 1290 1325 1124 1413 286 1612 1433 1713 621 1786 694 2008 1174 2076 1876 2171 2104 2175 2034 2242 917 2245 1541 2398 933 2416 2220 2422 1089 2569 2478 2575 2471 2646 2424 2682 638 2735 181 2770 1967 2802 1747 2879 697 2944 2063 2989 376 3126...
result:
ok Correct.
Test #34:
score: 0
Accepted
time: 30ms
memory: 7160kb
input:
92284 2 1 Duan 3 2 - 4 3 Duan 5 2 Duan 6 3 - 7 4 Duan 8 6 Duan 9 4 Duan 10 6 Duan 11 4 Duan 12 8 Chang 13 1 Duan 14 5 Duan 15 5 - 16 15 Duan 17 15 Duan 18 13 Chang 19 12 Duan 20 4 - 21 1 Duan 22 17 Duan 23 2 Duan 24 14 Duan 25 17 Duan 26 22 Duan 27 4 - 28 26 Duan 29 9 Duan 30 15 Duan 31 3 Duan 32 7 ...
output:
YES 13 18 9 84 8 116 132 133 125 140 12 179 49 183 35 193 127 206 87 220 194 249 47 267 51 270 236 280 158 281 248 334 339 375 141 386 108 388 14 394 302 395 217 404 402 488 173 506 113 528 101 587 21 598 104 657 358 686 230 697 32 713 190 721 332 738 420 740 544 776 160 791 703 800 145 817 828 879 ...
result:
ok Correct.
Test #35:
score: 0
Accepted
time: 27ms
memory: 7092kb
input:
93444 2 1 - 3 1 Duan 4 1 Duan 5 2 - 6 4 - 7 3 - 8 6 Duan 9 6 Duan 10 9 - 11 2 - 12 1 - 13 11 - 14 5 - 15 14 Duan 16 11 - 17 16 - 18 4 - 19 7 Duan 20 15 - 21 17 - 22 21 - 23 20 - 24 23 Duan 25 7 - 26 14 Duan 27 18 - 28 13 Duan 29 2 Duan 30 19 Duan 31 5 - 32 7 Duan 33 23 Duan 34 17 Duan 35 2 Duan 36 2...
output:
YES 245 279 35 386 391 461 543 612 60 707 766 847 422 879 481 893 712 914 818 968 346 1009 851 1037 74 1083 338 1127 50 1172 846 1190 546 1195 1181 1310 685 1333 811 1365 134 1431 428 1519 259 1584 298 1636 1166 1640 554 1696 413 1700 550 1713 770 1714 94 1734 1307 1743 223 1749 985 1760 895 1762 11...
result:
ok Correct.
Test #36:
score: 0
Accepted
time: 24ms
memory: 7268kb
input:
98244 2 1 Duan 3 1 Duan 4 3 Duan 5 4 Duan 6 4 Duan 7 4 Duan 8 5 Duan 9 8 Duan 10 5 Duan 11 9 Duan 12 3 Duan 13 11 Tong 14 5 Duan 15 5 Duan 16 12 Duan 17 2 Duan 18 3 Duan 19 4 Duan 20 2 Duan 21 6 Duan 22 21 Duan 23 1 - 24 15 - 25 20 Duan 26 8 Duan 27 13 Duan 28 12 Duan 29 22 Duan 30 24 Duan 31 21 Dua...
output:
YES 19 92 71 94 51 119 47 188 138 190 61 197 9 233 124 275 171 286 86 359 132 383 315 428 152 480 306 514 208 532 496 553 460 555 437 557 546 567 216 573 410 594 279 622 164 624 354 641 626 646 476 674 261 702 27 703 488 709 347 720 335 724 570 735 492 760 267 781 537 793 206 810 62 825 821 834 804 ...
result:
ok Correct.
Test #37:
score: 0
Accepted
time: 9ms
memory: 4456kb
input:
25284 2 1 Duan 3 2 - 4 3 - 5 3 Duan 6 2 Duan 7 3 Duan 8 1 Duan 9 5 - 10 4 - 11 5 Duan 12 4 Duan 13 1 Duan 14 4 - 15 10 Duan 16 8 - 17 13 - 18 15 - 19 12 - 20 16 Duan 21 6 Duan 22 2 Duan 23 19 - 24 12 - 25 2 - 26 19 Duan 27 5 - 28 4 - 29 9 - 30 12 Duan 31 7 Duan 32 31 - 33 21 - 34 24 Duan 35 28 Duan ...
output:
YES 8 39 15 50 21 131 116 133 11 162 122 178 144 221 190 269 242 320 268 401 125 402 63 447 477 488 134 503 236 505 328 517 5 532 22 621 675 685 498 693 671 716 400 725 98 764 531 792 737 845 200 870 219 876 690 908 79 909 288 918 368 929 851 939 147 941 216 946 927 975 304 1012 350 1034 568 1040 81...
result:
ok Correct.
Test #38:
score: 0
Accepted
time: 31ms
memory: 7112kb
input:
93246 2 1 Duan 3 2 Duan 4 3 Duan 5 1 - 6 4 Tong 7 4 Duan 8 4 Duan 9 8 - 10 6 Duan 11 2 Duan 12 1 Duan 13 11 Duan 14 8 Duan 15 1 Duan 16 8 Duan 17 10 Duan 18 3 Duan 19 1 Duan 20 18 Duan 21 10 Duan 22 14 Duan 23 11 Duan 24 19 Duan 25 21 Duan 26 17 Duan 27 24 Duan 28 24 Duan 29 17 Tong 30 23 Duan 31 17...
output:
YES 15 38 35 46 55 67 34 86 7 117 32 155 69 218 122 228 274 301 251 316 141 329 120 348 184 389 269 403 257 428 4 431 145 443 134 452 135 486 468 526 142 527 390 571 424 623 102 645 640 651 489 674 244 680 200 706 26 712 213 729 90 735 205 751 760 761 594 785 226 807 665 835 170 855 268 871 72 905 8...
result:
ok Correct.
Test #39:
score: 0
Accepted
time: 19ms
memory: 7228kb
input:
99837 2 1 - 3 1 - 4 3 Duan 5 2 Duan 6 5 Duan 7 3 Duan 8 5 - 9 6 Duan 10 4 - 11 4 - 12 6 Duan 13 8 - 14 7 - 15 10 Duan 16 11 Duan 17 8 Duan 18 6 - 19 13 Duan 20 16 Duan 21 20 - 22 19 Chang 23 4 Duan 24 13 Duan 25 21 - 26 17 Duan 27 7 Duan 28 8 - 29 3 - 30 18 - 31 21 Duan 32 27 Duan 33 21 Duan 34 17 -...
output:
YES 19 22 6 56 54 69 63 185 287 331 125 385 159 425 398 428 129 437 73 519 376 541 283 580 303 593 175 672 257 715 227 726 643 731 369 738 626 741 166 825 380 829 727 838 144 868 840 874 867 901 516 904 284 968 827 995 118 996 993 1040 574 1071 210 1115 124 1139 231 1177 630 1244 530 1249 789 1253 8...
result:
ok Correct.
Test #40:
score: 0
Accepted
time: 23ms
memory: 7060kb
input:
91248 2 1 Duan 3 1 Duan 4 1 Duan 5 2 Duan 6 3 Duan 7 3 Chang 8 2 Duan 9 1 Duan 10 7 Duan 11 10 Duan 12 4 Duan 13 2 Duan 14 11 Duan 15 6 Duan 16 8 Duan 17 7 Duan 18 2 Duan 19 15 Duan 20 4 Duan 21 7 Duan 22 6 Duan 23 6 Duan 24 20 Duan 25 13 Duan 26 22 Duan 27 5 Duan 28 19 Duan 29 14 Duan 30 12 - 31 8 ...
output:
YES 3 7 9 89 28 95 49 112 24 141 73 166 67 202 77 208 94 258 63 278 236 353 40 354 18 432 333 476 69 500 230 505 492 546 343 563 82 566 213 570 284 584 574 668 23 681 701 782 101 813 414 841 487 849 554 861 596 865 751 877 551 908 296 911 273 912 57 1000 830 1012 117 1027 909 1033 660 1038 972 1044 ...
result:
ok Correct.
Test #41:
score: 0
Accepted
time: 23ms
memory: 7028kb
input:
93538 2 1 - 3 2 - 4 2 - 5 3 Duan 6 4 - 7 4 - 8 2 - 9 1 - 10 7 - 11 4 Duan 12 8 - 13 9 - 14 1 Duan 15 7 Duan 16 3 - 17 5 - 18 14 Duan 19 5 - 20 7 - 21 15 Duan 22 9 - 23 8 - 24 16 Duan 25 5 Duan 26 6 Duan 27 10 - 28 7 - 29 21 Duan 30 1 - 31 18 - 32 13 - 33 6 - 34 28 - 35 16 Duan 36 32 Duan 37 22 - 38 ...
output:
YES 86 211 212 235 223 348 328 447 283 498 291 514 508 532 11 577 134 581 189 592 187 612 255 698 248 735 197 803 116 860 805 891 292 903 781 941 262 945 152 1000 547 1013 18 1069 1028 1270 677 1332 362 1492 1261 1520 1128 1576 435 1670 480 1778 700 1839 887 1876 933 2003 210 2023 1634 2032 1571 204...
result:
ok Correct.
Test #42:
score: 0
Accepted
time: 21ms
memory: 7080kb
input:
92384 2 1 Duan 3 2 - 4 3 Duan 5 3 Duan 6 3 - 7 2 Duan 8 1 - 9 7 Duan 10 5 Chang 11 4 - 12 3 Duan 13 7 - 14 9 Duan 15 14 Chang 16 3 Duan 17 6 Duan 18 10 Duan 19 17 Duan 20 10 - 21 2 Duan 22 10 - 23 5 Duan 24 18 - 25 11 - 26 13 Duan 27 12 Duan 28 1 - 29 18 Duan 30 28 Duan 31 28 - 32 16 - 33 27 Duan 34...
output:
YES 5 10 51 63 40 130 69 161 105 254 15 294 238 310 127 326 78 330 122 374 385 428 7 552 281 567 53 645 144 692 542 705 453 721 699 736 26 792 283 850 725 861 391 904 47 914 755 926 682 995 554 1094 272 1095 77 1114 401 1144 360 1206 576 1257 472 1260 960 1282 586 1284 644 1299 36 1345 1231 1355 120...
result:
ok Correct.
Test #43:
score: 0
Accepted
time: 2ms
memory: 3304kb
input:
1
output:
YES
result:
ok Correct.