QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#435115 | #5261. Kolorowy wąż | Terryjoy | 100 ✓ | 136ms | 23768kb | C++14 | 1.0kb | 2024-06-08 18:58:09 | 2024-06-08 18:58:11 |
Judging History
answer
#include <iostream>
using namespace std;
const int M = 2003, N = 1000006;
int m, p, n, w, k, mmp[M][M], x, y, val[N], tim = 1, len, t[M][M];
int read(){
int x = 0;
char a = getchar();
while(a < '0' || '9' < a) a = getchar();
while('0' <= a && a <= '9') x = (x << 1) + (x << 3) + (a ^ 48), a = getchar();
return x;
}
void write(int x){
if(x > 9) write(x / 10);
putchar(x % 10 | 48);
}
int main(){
m = read(), p = read(), n = read();
for(int i = 1; i <= p; ++ i){
w = read(), k = read();
mmp[w][k] = read() + 1;
}
t[x = 1][y = 1] = 1, len = 1;
for(int i = 1; i <= n; ++ i){
char a = getchar();
while(a < 'A' || 'Z' < a) a = getchar();
if(a == 'Z'){
w = read(), k = read();
if(tim - t[w][k] >= len) fputs("-1\n", stdout);
else write(val[len - (tim - t[w][k])]), putchar('\n');
}
else{
if(a == 'G') x --;
else if(a == 'D') ++ x;
else if(a == 'L') y --;
else ++ y;
if(!t[x][y] && mmp[x][y]) val[++ len] = mmp[x][y] - 1;
t[x][y] = ++ tim;
}
}
return 0;
}
詳細信息
Subtask #1:
score: 20
Accepted
Test #1:
score: 20
Accepted
time: 1ms
memory: 7640kb
input:
2 3 2000 2 1 2 1 2 0 2 2 3 P D L Z 1 2 G Z 2 1 P Z 2 2 Z 2 1 D L Z 2 1 G P D Z 1 2 L G P D Z 2 2 L Z 2 2 Z 2 2 Z 2 1 Z 1 2 Z 2 2 G P D L G P D L G P Z 1 1 D L Z 1 1 Z 1 1 Z 1 2 G Z 2 2 P D L G Z 1 2 Z 1 2 P Z 1 1 D L Z 1 1 G P D L G P Z 2 1 D L Z 1 1 Z 2 2 G P D L G Z 2 1 Z 1 1 Z 2 2 P D L G Z 1 1 P...
output:
0 3 0 0 2 3 2 3 3 2 0 3 3 0 0 0 0 0 0 3 0 0 0 3 3 2 0 2 0 2 3 3 0 2 0 0 2 0 2 0 0 3 0 2 3 0 0 0 2 3 3 0 0 0 2 2 0 3 2 0 0 0 0 2 2 0 2 2 2 2 3 0 3 2 3 0 2 0 3 3 0 3 2 3 0 3 3 2 0 0 2 0 0 3 0 0 0 2 2 3 3 0 3 0 2 2 0 0 2 0 3 0 0 2 3 0 2 0 2 0 0 0 2 0 2 3 0 2 0 2 3 0 2 0 2 3 2 0 2 3 2 0 0 0 2 0 0 0 0 0 ...
result:
ok 700 lines
Test #2:
score: 20
Accepted
time: 0ms
memory: 7876kb
input:
20 399 2000 5 20 207 5 13 172 9 2 397 5 18 191 11 5 217 11 18 193 10 17 15 9 5 266 10 16 324 14 11 180 16 9 317 1 15 185 2 16 78 3 14 225 2 19 326 1 8 80 3 9 164 8 16 366 7 8 51 2 15 230 17 8 44 1 17 287 18 8 377 11 12 315 14 15 335 8 4 20 4 2 79 9 1 94 4 15 257 15 8 195 15 7 236 15 9 13 12 5 376 3 ...
output:
0 24 -1 24 24 248 320 -1 80 0 287 -1 393 230 326 -1 230 281 373 68 0 -1 94 323 326 225 227 105 68 160 304 310 248 323 29 -1 206 -1 208 320 273 145 320 218 281 326 160 -1 -1 58 24 47 229 29 246 87 133 129 177 31 185 97 398 85 48 180 328 315 9 25 -1 152 31 68 87 175 137 304 317 147 96 58 265 320 39 0 ...
result:
ok 500 lines
Test #3:
score: 20
Accepted
time: 1ms
memory: 7868kb
input:
20 399 2000 6 5 267 11 5 142 10 3 377 10 13 286 9 7 181 20 7 373 13 11 134 6 8 154 11 13 269 12 11 135 14 2 374 6 16 44 12 15 312 18 19 36 11 12 382 20 19 310 13 12 390 6 17 39 12 9 286 18 14 40 13 16 141 4 8 194 12 10 87 4 5 239 5 1 108 17 8 167 19 19 16 20 9 341 8 15 383 7 15 160 4 14 212 15 16 28...
output:
-1 0 0 -1 0 0 0 0 0 210 210 210 0 386 0 386 210 0 386 0 0 210 210 386 0 15 0 -1 386 386 15 0 15 210 386 386 0 0 210 64 0 15 386 15 -1 210 210 0 210 386 -1 386 15 0 0 0 210 64 0 210 91 64 288 288 386 112 -1 386 175 288 91 91 91 -1 -1 64 112 0 0 15 288 331 288 64 64 288 -1 332 64 331 112 112 64 210 38...
result:
ok 1601 lines
Test #4:
score: 20
Accepted
time: 2ms
memory: 9808kb
input:
300 2000 2000 77 120 61443 259 250 88371 196 155 42599 139 153 89021 250 131 36183 276 4 40656 142 1 61936 208 109 67149 216 97 23882 175 108 30969 105 57 46184 46 271 38166 28 148 87278 47 7 43967 115 34 19608 244 155 22908 50 281 57566 160 217 78151 270 17 64550 236 174 50338 150 190 3254 85 250 7...
output:
0 0 -1 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 10995 10995 0 0 10995 0 0 0 10995 -1 10995 -1 0 10995 47013 -1 47013 10995 47013 -1 0 10995 47013 10995 10995 10995 0 0 0 10995 10995 47013 47013 41517 -1 -1 0 10995 1099...
result:
ok 500 lines
Test #5:
score: 20
Accepted
time: 2ms
memory: 8020kb
input:
300 20 2000 235 52 83799 28 125 74053 159 193 11386 131 264 80712 251 289 5656 253 1 35419 292 174 60922 115 98 23250 13 102 9431 113 55 58865 108 218 27903 129 93 43216 77 216 29787 281 182 44559 47 3 52345 195 172 38398 283 173 19841 259 152 10187 220 149 73535 253 182 9316 Z 1 1 D Z 2 1 Z 3 1 Z 2...
output:
0 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 -1 0 0 0 -1 -1 -1 0 -1 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 ...
result:
ok 1000 lines
Test #6:
score: 20
Accepted
time: 1ms
memory: 7924kb
input:
300 2000 2000 217 54 2202 26 234 59074 281 127 85940 105 158 28164 269 110 8731 102 242 61898 245 111 40408 14 262 44385 279 273 14400 172 25 80783 128 161 28050 97 55 52049 131 8 22731 160 24 30254 286 172 82565 88 195 25989 87 75 83029 193 49 17337 138 30 46246 194 42 48165 119 273 30022 51 256 38...
output:
0 0 0 0 0 -1 59026 0 0 57684 59026 57684 55 0 57684 57684 59026 59026 57684 73615 57684 0 0 -1 57684 73615 57684 -1 -1 76971 -1 -1 -1 0 -1 -1 57684 55 76971 -1 0 59026 24742 -1 59026 55 24742 -1 57684 76971 76971 24418 59026 74064 32538 55 0 59026 59026 74064 79542 76971 24418 -1 24742 73615 17583 7...
result:
ok 200 lines
Subtask #2:
score: 20
Accepted
Dependency #1:
100%
Accepted
Test #7:
score: 20
Accepted
time: 3ms
memory: 8168kb
input:
100 9999 50000 19 43 9347 64 4 518 29 100 2390 87 84 6073 23 46 7577 52 47 186 86 40 394 78 78 8523 95 40 1802 13 6 3727 26 80 7090 100 69 9645 90 46 3748 25 19 7834 96 72 4015 56 4 7318 57 42 8557 27 59 7792 54 99 1993 19 40 9374 86 29 5400 73 38 5068 1 50 6770 65 89 8835 4 35 6027 42 42 3602 98 24...
output:
8415 2508 3700 2576 2576 2785 3700 8415 2576 5765 143 3136 4623 -1 385 1673 -1 1453 -1 8185 9654 824 1453 3237 1673 9750 8123 -1 8944 1460 -1 824 6770 2785 3968 9863 -1 6210 2013 1460 6459 2785 -1 1307 9219 9079 8193 6048 8123 8273 2785 9433 6677 8310 6433 3700 8500 16 790 3382 445 9239 6245 1956 -1...
result:
ok 10000 lines
Test #8:
score: 20
Accepted
time: 2ms
memory: 10792kb
input:
200 39999 50000 40 93 38469 40 3 10906 168 36 9256 192 27 34263 115 123 22212 105 132 17909 29 95 16482 134 153 16976 101 15 5833 193 92 2009 86 190 27687 139 102 39505 56 84 24724 7 128 30370 78 129 9953 95 5 34620 95 118 22145 41 173 4666 200 156 32641 186 4 37549 130 29 7961 180 57 27729 14 105 3...
output:
0 0 33608 29475 33608 5117 -1 7483 8479 36402 25284 8479 6724 -1 26843 17839 7593 39522 28278 27704 33460 19529 4213 26058 32984 4983 29676 39042 37067 33688 1970 35534 29801 912 16127 29475 25342 11277 22397 19943 -1 -1 2852 28755 28943 27703 36914 14360 14345 37006 19756 3901 10305 -1 11281 4213 3...
result:
ok 5000 lines
Test #9:
score: 20
Accepted
time: 2ms
memory: 10380kb
input:
600 10000 50000 561 504 173737 576 181 301179 237 235 326111 439 65 75162 83 367 210063 110 145 10459 227 383 161355 394 573 173666 369 74 6452 379 561 132543 320 187 127965 528 40 349850 582 232 319991 198 11 18553 391 471 210246 163 212 185882 362 124 353745 106 175 134283 436 382 123411 222 99 11...
output:
0 -1 0 0 -1 0 -1 -1 0 0 0 0 0 0 0 -1 0 0 0 0 261633 -1 0 0 261633 0 0 261633 261633 -1 0 0 261633 -1 261633 0 0 0 0 0 155913 0 261633 0 0 0 261633 261633 -1 155913 155913 -1 155913 155913 261633 -1 -1 261633 -1 261633 261633 155913 261633 155913 155913 -1 0 261633 -1 155913 155913 230670 155913 -1 -...
result:
ok 20000 lines
Test #10:
score: 20
Accepted
time: 0ms
memory: 8152kb
input:
100 9999 50000 10 47 1622 23 52 3866 75 43 1784 81 32 3569 93 77 2474 34 53 1973 61 9 5849 9 21 5299 8 60 3751 64 2 8872 1 29 5020 70 93 9837 5 1 2449 32 36 4806 90 35 1370 68 61 2422 95 18 1390 28 47 8284 84 98 3250 92 42 3150 83 36 8241 71 65 113 84 78 9506 44 61 5994 1 11 1933 62 62 791 57 20 808...
output:
0 0 8802 6749 2126 0 8422 -1 6749 2143 5472 2296 7576 5020 6674 8029 -1 4547 0 0 6674 4304 4884 4468 5472 3237 5599 2143 474 5240 172 9797 2157 8029 5240 8422 1943 -1 1836 3237 2931 -1 4685 5721 -1 2126 4600 -1 3667 4547 -1 4468 3419 6787 1457 6674 4672 4468 6558 6481 4023 6235 -1 -1 9610 7923 4195 ...
result:
ok 15000 lines
Test #11:
score: 20
Accepted
time: 4ms
memory: 10116kb
input:
800 50000 50000 449 321 324011 150 364 45500 753 255 461350 252 469 406611 407 654 323057 60 565 108778 8 67 637325 76 299 258213 342 114 69245 576 55 67018 241 541 182668 356 703 174868 571 696 219875 4 473 127058 269 209 610761 167 619 373484 571 698 507543 542 72 335411 373 119 626549 435 246 533...
output:
0 0 -1 0 153857 0 99631 153857 153857 -1 99631 0 153857 0 -1 176175 99631 153857 176175 553337 176175 176175 445896 153857 -1 627905 258030 -1 627905 242395 -1 538963 99631 445896 445896 176175 99631 176175 445896 579023 176175 242395 445896 536493 379224 -1 -1 579023 539797 126243 568129 99631 5681...
result:
ok 5000 lines
Test #12:
score: 20
Accepted
time: 9ms
memory: 9848kb
input:
800 50000 50000 257 672 498090 547 192 269078 370 52 391611 607 453 123260 343 680 253570 757 210 385472 469 31 579761 723 240 366944 584 354 114353 286 269 316429 110 665 202726 599 302 246734 474 440 263271 120 651 259428 617 661 348426 68 439 283163 47 748 386986 284 783 292638 176 687 535109 769...
output:
-1 0 160424 0 0 0 0 160424 160424 461484 0 160424 461484 160424 482761 0 482761 0 0 639559 0 362252 -1 160424 0 362252 460154 461484 228958 -1 160424 639559 639559 172019 362252 172019 -1 0 172019 590060 590060 228958 362252 228958 -1 -1 600372 -1 461484 460154 214295 639559 448616 160424 460154 448...
result:
ok 10000 lines
Subtask #3:
score: 20
Accepted
Test #13:
score: 20
Accepted
time: 35ms
memory: 7120kb
input:
200 1000 1000000 193 196 0 110 183 0 78 72 0 160 46 0 185 62 0 61 56 0 122 60 0 79 188 0 100 171 0 112 60 0 141 191 0 122 58 0 79 181 0 28 24 0 115 121 0 26 17 0 103 89 0 100 138 0 58 5 0 97 174 0 137 40 0 112 104 0 45 142 0 187 17 0 45 135 0 193 152 0 13 178 0 174 36 0 157 196 0 104 55 0 165 46 0 1...
output:
0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 -1 -1 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 0 -1 -1 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 0 -1 -1 0 0 0 -1 0 -1 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 -1 -1 0 0 -1 0 0 0 -1 0 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
result:
ok 600000 lines
Test #14:
score: 20
Accepted
time: 9ms
memory: 15316kb
input:
800 50000 1000000 363 586 0 60 552 0 24 34 0 736 678 0 269 77 0 486 152 0 133 388 0 141 311 0 673 83 0 339 392 0 341 19 0 393 177 0 177 436 0 668 715 0 248 507 0 528 603 0 125 392 0 692 294 0 705 500 0 538 486 0 30 61 0 512 505 0 296 466 0 252 493 0 222 242 0 594 746 0 705 280 0 530 150 0 81 601 0 4...
output:
-1 0 0 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 -1 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 -1 0 -1 0 0 0 0 0 0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 -1 -1 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 -1 0 0 -1 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 -1 0...
result:
ok 50000 lines
Test #15:
score: 20
Accepted
time: 5ms
memory: 6656kb
input:
200 100 1000000 93 170 0 150 180 0 164 30 0 190 22 0 14 101 0 190 71 0 98 110 0 89 121 0 50 21 0 50 117 0 184 83 0 127 71 0 166 5 0 15 62 0 47 63 0 74 112 0 150 68 0 97 108 0 164 193 0 88 57 0 70 84 0 127 108 0 24 183 0 152 51 0 146 152 0 59 172 0 101 109 0 27 95 0 24 94 0 105 107 0 80 182 0 19 152 ...
output:
0 0 -1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 -1 0 0 0 0 -1 0 0 0 -1 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 -1 0 -1 -1 0 -1 0 0 0 0 -1 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0...
result:
ok 10000 lines
Test #16:
score: 20
Accepted
time: 136ms
memory: 23284kb
input:
2000 1000000 1000000 558 246 0 254 1066 0 188 545 0 1212 1235 0 1522 1792 0 1588 713 0 955 862 0 527 159 0 1323 1041 0 1699 33 0 644 1106 0 67 745 0 1804 1061 0 1501 1979 0 168 1266 0 1282 626 0 359 1509 0 1509 1983 0 585 1199 0 119 1927 0 620 802 0 391 1248 0 433 1488 0 934 1569 0 710 1290 0 336 82...
output:
0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 -1 0 -1 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 -1 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 -1 0 -1 0 -1 -1 -1 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 500000 lines
Test #17:
score: 20
Accepted
time: 116ms
memory: 23768kb
input:
2000 1000000 1000000 514 839 0 1065 1696 0 405 1204 0 385 587 0 1459 1883 0 318 1169 0 718 1289 0 1514 1195 0 928 1095 0 1380 230 0 1001 1051 0 597 800 0 1897 1916 0 1211 1725 0 788 1449 0 169 308 0 1111 1290 0 1213 545 0 1226 1303 0 692 62 0 868 1587 0 1744 521 0 754 1699 0 772 1139 0 1381 247 0 18...
output:
0 0 0 0 -1 0 0 -1 0 0 0 0 0 0 0 -1 0 0 0 -1 0 -1 -1 0 0 -1 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 0 -1 0 -1 0 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 0 0 -1 0 -1 0 0 0 0 -1 0 0 0 0 0 -1 0 0 0 -1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -1 0 0 0 0 0 -1 -1 0 0 0 0 0 0 -1 0 ...
result:
ok 100000 lines
Subtask #4:
score: 0
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Test #18:
score: 0
Accepted
time: 63ms
memory: 15132kb
input:
500 249999 1000000 262 478 44640 113 453 196831 215 48 63657 416 102 20881 457 395 174001 75 487 210081 181 368 129118 172 195 26953 258 290 217616 314 433 63747 216 143 82131 93 110 2594 445 414 138513 472 158 92431 253 19 68152 396 455 80646 325 369 124418 129 348 29970 30 2 29431 461 66 71594 14 ...
output:
0 0 124476 0 0 0 124476 248891 248891 77797 82700 -1 213080 57609 56664 -1 38832 248891 -1 55733 124476 82700 77797 160099 0 -1 208631 174855 -1 114838 57609 -1 213080 82700 4355 97331 196788 185247 -1 191628 160900 216923 160900 245167 248891 56664 200338 65180 125472 82700 51163 246679 245167 9733...
result:
ok 400000 lines
Extra Test:
score: 0
Extra Test Passed