QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#444334 | #8646. Card Collection | Qwerty1232# | 11 | 7ms | 4164kb | C++23 | 3.3kb | 2024-06-15 18:23:55 | 2024-06-15 18:23:55 |
Judging History
answer
#include <bits/stdc++.h>
void unique(auto& vec) {
std::sort(vec.begin(), vec.end());
vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}
int32_t main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<std::pair<int, int>> input(n), quer(m);
for (auto& [u, v] : input) {
std::cin >> u >> v;
}
for (auto& [u, v] : quer) {
std::cin >> u >> v;
}
std::vector<int> all_x, all_y;
for (auto& [u, v] : quer) {
all_x.push_back(u);
all_x.push_back(u - 1);
all_y.push_back(v);
all_y.push_back(v - 1);
}
all_x.push_back(1.1e9);
all_y.push_back(1.1e9);
unique(all_x);
unique(all_y);
int w = all_x.size(), h = all_y.size();
for (auto& [u, v] : input) {
u = std::lower_bound(all_x.begin(), all_x.end(), u) - all_x.begin();
v = std::lower_bound(all_y.begin(), all_y.end(), v) - all_y.begin();
assert(u != w && v != h);
}
for (auto& [u, v] : quer) {
u = std::lower_bound(all_x.begin(), all_x.end(), u) - all_x.begin();
v = std::lower_bound(all_y.begin(), all_y.end(), v) - all_y.begin();
assert(u != w && v != h);
}
std::vector<std::vector<std::vector<std::vector<char>>>> dp(n, std::vector<std::vector<std::vector<char>>>(n, std::vector<std::vector<char>>(w, std::vector<char>(h))));
for (int i = 0; i < n; i++) {
dp[i][i][input[i].first][input[i].second] = 1 + 4;
}
for (int i = 1; i < n; i++) {
for (int j = i - 1; j >= 0; j--) {
for (int t = j; t < i; t++) {
for (int a = 0; a < w; a++) {
for (int b = 0; b < h; b++) {
if (!dp[j][t][a][b]) {
continue;
}
for (int c = 0; c < w; c++) {
for (int d = 0; d < h; d++) {
if (!dp[t + 1][i][c][d]) {
continue;
}
for (char ch = 0; ch < 4; ch++) {
if ((dp[j][t][a][b] & 1 << ch) && (dp[t + 1][i][c][d] & 1 << ch)) {
if (ch == 0 || ch == 3) {
dp[j][i][std::min(a, c)][std::min(b, d)] |= 1 << ch;
dp[j][i][std::max(a, c)][std::max(b, d)] |= 1 << ch;
} else {
}
}
}
}
}
if (dp[i][j][a][b] & 1) {
dp[i][j][a][b] |= 2;
}
if (dp[i][j][a][b] & 4) {
dp[i][j][a][b] |= 8;
}
}
}
}
}
}
for (int i = 0; i < m; i++) {
if (dp[0][n - 1][quer[i].first][quer[i].second]) {
std::cout << i + 1 << " ";
}
}
std::cout << std::endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 11
Accepted
Test #1:
score: 11
Accepted
time: 0ms
memory: 3572kb
input:
2 10 171631799 561094698 171631799 867698918 126573648 561094698 171631799 867698918 171631799 561094698 126573648 561094698 126573648 561094698 171631799 561094698 126573648 561094698 126573648 561094698 126573648 561094698 171631799 561094698
output:
2 3 6 10
result:
ok 4 number(s): "2 3 6 10"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
3 10 713180371 43103927 713180371 136832929 853543805 251852293 892623928 251852293 713180371 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 853543805 43103927 892623928 136832929 713180371 43103927 892623928 251852293
output:
2 3 6 9
result:
ok 4 number(s): "2 3 6 9"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3640kb
input:
4 10 254412080 855555783 254412080 534954259 610506813 184822793 804271098 233942602 804271098 233942602 536633825 184822793 254412080 855555783 804271098 233942602 536633825 233942602 254412080 855555783 804271098 534954259 610506813 534954259 536633825 184822793 536633825 855555783
output:
1 3 4 6 7 8
result:
ok 6 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
5 10 148547041 170447714 617759855 170447714 617759855 963162312 148547041 948767426 423489361 460053818 423489361 460053818 817714720 948767426 617759855 673099807 617759855 963162312 617759855 673099807 423489361 460053818 423489361 460053818 817714720 948767426 817714720 170447714 148547041 67309...
output:
1 4 6 7
result:
ok 4 number(s): "1 4 6 7"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
6 10 452189481 369706489 974106249 369706489 152471743 55874110 152471743 7767562 623180600 783682263 116778263 783682263 974106249 369706489 452189481 7767562 623180600 7767562 116778263 783682263 330861484 7767562 452189481 640079581 974106249 640079581 623180600 783682263 974106249 7767562 116778...
output:
1 4 8
result:
ok 3 number(s): "1 4 8"
Test #6:
score: 0
Accepted
time: 1ms
memory: 3896kb
input:
7 10 546365360 29458595 459505526 682968936 892069847 113227141 892069847 682968936 459505526 895773339 436538726 29458595 892069847 29458595 892069847 21442381 200908509 682968936 84249914 782064261 691849455 682968936 691849455 682968936 691849455 21442381 691849455 682968936 691849455 21442381 84...
output:
result:
ok 0 number(s): ""
Test #7:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
8 10 53884460 816621582 931458006 534340303 53884460 621933704 317941616 487589985 53884460 793793344 831491668 487589985 53884460 816621582 53884460 417129074 831491668 417129074 317941616 534340303 395845824 793793344 395845824 417129074 317941616 166559933 100528187 487589985 83144683 816621582 8...
output:
2 10
result:
ok 2 number(s): "2 10"
Test #8:
score: 0
Accepted
time: 1ms
memory: 3708kb
input:
9 10 703128946 628411749 703128946 876135124 678057110 783023566 563107567 908344997 255577987 177945114 703128946 177945114 519769912 951772210 678057110 470396423 703128946 470396423 563107567 783023566 813952930 470396423 230207898 177945114 230207898 628411749 519769912 555485281 703128946 78302...
output:
1 6
result:
ok 2 number(s): "1 6"
Test #9:
score: 0
Accepted
time: 1ms
memory: 3840kb
input:
10 10 411828800 587312736 368564282 297078085 368564282 265187364 287645241 405039514 368564282 535066135 368564282 265187364 701629305 581674146 894581821 581674146 600278299 347261251 368564282 390901645 633230417 151902557 287645241 297078085 1782717 405039514 287645241 587312736 894581821 587312...
output:
2 5 7
result:
ok 3 number(s): "2 5 7"
Test #10:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
11 10 594865443 637250974 223004376 637250974 785025296 887146590 120666718 887146590 31665956 652873089 594865443 887146590 1682073 112213166 31665956 121276446 785025296 121276446 28305142 652873089 28305142 661968377 1682073 120498688 938018458 887146590 120666718 112213166 28305142 112213166 223...
output:
10
result:
ok 1 number(s): "10"
Test #11:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
12 10 39186066 168002748 671722214 32295292 39186066 469855569 442075770 469855569 689698028 968471023 3489285 168002748 671722214 968471023 182809077 689539890 481317320 742954502 265274602 32295292 265274602 26013512 481317320 742954502 976556207 168425358 689698028 32295292 749415058 545907259 24...
output:
10
result:
ok 1 number(s): "10"
Test #12:
score: 0
Accepted
time: 1ms
memory: 3956kb
input:
13 10 527355089 377970728 552459003 455747923 709625462 510634723 552459003 377970728 731571039 951161417 232811148 951161417 552459003 658700181 232811148 377970728 518940837 455747923 455586174 378372201 219157258 378372201 219157258 377970728 709625462 385691279 455586174 510634723 915002219 1039...
output:
1 4 7 8 10
result:
ok 5 number(s): "1 4 7 8 10"
Test #13:
score: 0
Accepted
time: 2ms
memory: 4052kb
input:
14 10 118092342 284486250 927338949 433938384 402661724 978896809 647730583 672355271 31848729 951232518 735207774 379785691 647730583 976797409 118092342 976797409 16895438 951232518 266079358 317991591 402661724 759687663 927338949 672355271 384578818 379785691 927338949 675446949 647730583 672355...
output:
1 2 9
result:
ok 3 number(s): "1 2 9"
Test #14:
score: 0
Accepted
time: 1ms
memory: 3832kb
input:
15 10 180664786 545082798 348151122 545082798 945365791 568927334 87112728 22695274 969050024 993697033 76897725 568927334 946081941 721317554 736012091 124380018 76897725 993697033 969050024 297352406 87112728 22695274 477303819 152140956 497190005 127179215 477303819 957952273 946081941 297352406 ...
output:
2 3
result:
ok 2 number(s): "2 3"
Test #15:
score: 0
Accepted
time: 2ms
memory: 3864kb
input:
16 10 950185079 359470460 717527338 766264034 950185079 464367361 702133494 562464640 47221737 933850433 804214161 68526353 835127535 923127189 663871966 429877028 663871966 933850433 663871966 860592052 717527338 159513156 817202184 970491880 835127535 475614319 519002985 475614319 109565532 137441...
output:
5 9
result:
ok 2 number(s): "5 9"
Test #16:
score: 0
Accepted
time: 3ms
memory: 3932kb
input:
17 10 785164241 654900960 360828785 824839755 439791874 641288092 577364156 862808499 668131950 862808499 893897612 712643610 893897612 596494049 736363695 306279255 668131950 262689126 141356696 306279255 141356696 559915287 785164241 712643610 785164241 862808499 785164241 91314622 657093012 89959...
output:
1 2 4 7 8
result:
ok 5 number(s): "1 2 4 7 8"
Test #17:
score: 0
Accepted
time: 5ms
memory: 3896kb
input:
18 10 634436200 539568435 939344787 325688918 488541626 821095697 430879210 182007328 634436200 676635380 863100947 105320937 634436200 259039153 155697449 650750783 863100947 290661066 904360323 275647130 148773803 836392810 155697449 275647130 904360323 325688918 242889289 395936619 863100947 8363...
output:
4 5 8 10
result:
ok 4 number(s): "4 5 8 10"
Test #18:
score: 0
Accepted
time: 4ms
memory: 3848kb
input:
19 10 643978171 286398879 496772316 971744093 955019965 629209809 874944857 162312003 813096582 680350320 973954693 690315188 387049024 971744093 817521662 629209809 17782710 227578391 308611155 855159132 817521662 286398879 222858816 971744093 222858816 532541541 704414451 629209809 17782710 227578...
output:
result:
ok 0 number(s): ""
Test #19:
score: 0
Accepted
time: 7ms
memory: 4024kb
input:
20 10 339497023 613254335 277080109 869002717 498404000 182716214 838620251 613254335 774235215 599908689 321477480 52537358 406499846 787324761 498404000 867048589 339497023 265303890 653823018 594937507 277080109 856711907 774235215 150629026 339497023 613254335 845764830 867048589 339497023 85671...
output:
5 9
result:
ok 2 number(s): "5 9"
Test #20:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
2 1 573537298 133184345 819019960 446972624 573537298 133184345
output:
1
result:
ok 1 number(s): "1"
Test #21:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
2 10 215463781 963544789 417194171 381706359 215463781 381706359 417194171 963544789 417194171 381706359 215463781 381706359 215463781 381706359 215463781 381706359 417194171 963544789 215463781 381706359 417194171 963544789 215463781 381706359
output:
1 2 4 5 6 7 8 9 10
result:
ok 9 numbers
Test #22:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
2 10 347064832 492954369 276208042 238639351 347064832 492954369 276208042 492954369 347064832 238639351 276208042 492954369 276208042 238639351 276208042 492954369 347064832 492954369 276208042 492954369 347064832 238639351 347064832 492954369
output:
1 5 7 10
result:
ok 4 number(s): "1 5 7 10"
Test #23:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 10 59424469 214378961 467302957 920237929 467302957 214378961 467302957 920237929 467302957 214378961 467302957 920237929 467302957 214378961 467302957 214378961 467302957 920237929 467302957 214378961 467302957 920237929 467302957 920237929
output:
2 4 7 9 10
result:
ok 5 number(s): "2 4 7 9 10"
Test #24:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
3 10 199016579 737474160 269172900 902060853 363682951 999857037 199016579 999857037 363682951 737474160 363682951 737474160 199016579 737474160 363682951 999857037 363682951 902060853 363682951 737474160 199016579 737474160 269172900 902060853 269172900 737474160
output:
4 5 8 9
result:
ok 4 number(s): "4 5 8 9"
Test #25:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
3 10 546485825 847511917 181508698 729251744 262746395 577803673 546485825 729251744 546485825 577803673 262746395 847511917 546485825 729251744 546485825 577803673 262746395 577803673 546485825 847511917 262746395 577803673 181508698 847511917 181508698 577803673
output:
6 7 8 10
result:
ok 4 number(s): "6 7 8 10"
Test #26:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
3 10 237380807 513263480 564217004 186570115 980960156 646344876 980960156 646344876 237380807 646344876 980960156 646344876 980960156 513263480 980960156 513263480 564217004 513263480 980960156 186570115 237380807 513263480 237380807 513263480 980960156 186570115
output:
1 3 6 8 9
result:
ok 5 number(s): "1 3 6 8 9"
Test #27:
score: 0
Accepted
time: 3ms
memory: 3764kb
input:
15 10 624534653 795252871 948654092 55283897 925850942 516359844 291755097 717356990 550592491 128816565 821582441 517445939 994534468 342358076 26658991 396148487 649608935 585141111 323180864 608811044 265317796 85810941 124933870 521198693 547685531 600579720 271150336 559571739 242219192 7700636...
output:
1 2 3 4 8 9
result:
ok 6 numbers
Test #28:
score: 0
Accepted
time: 4ms
memory: 4164kb
input:
16 10 83190470 209266752 880371594 540332431 77621971 311011586 207583928 515840494 210164058 16324657 557379175 66621069 583090455 503874482 155148044 798469757 997210630 599613989 425284838 540392415 814293641 704949575 371097849 755590192 748854182 185159646 764105570 723184963 281807551 22356411...
output:
1 2 3 4 5 6 7 9 10
result:
ok 9 numbers
Test #29:
score: 0
Accepted
time: 3ms
memory: 3876kb
input:
17 10 335815281 733974183 996064097 204520072 806805395 978835797 278538265 788397455 993251528 550268353 598157139 171152822 752267659 708459589 720836211 683278789 104083774 172399908 396138427 816227937 454892965 632042288 630038886 668199869 907561802 996410213 244931242 610519539 474601248 7303...
output:
1 6 8
result:
ok 3 number(s): "1 6 8"
Test #30:
score: 0
Accepted
time: 7ms
memory: 3924kb
input:
18 10 461958391 283363776 820708759 240820111 809183522 564946300 274367350 887675067 808876603 652655193 242336368 71989816 35682865 592736787 598975260 11034644 432130229 841406481 617636775 764446022 39223975 938369951 608686441 406829225 979705068 458377101 609019396 321322678 993501055 30534219...
output:
1 2 3 5 6 7 8 9 10
result:
ok 9 numbers
Test #31:
score: 0
Accepted
time: 7ms
memory: 4000kb
input:
19 10 935306669 629155511 75497873 924414411 568314611 976194131 623493055 355890466 492224421 999834286 553317256 546504008 409428707 857511314 933067983 202850910 458115220 344652086 144924200 447572677 301600067 34784059 519123285 847853731 447663066 411079314 846416609 480411419 22568709 1531818...
output:
1 2 3 4 5 6 7 9 10
result:
ok 9 numbers
Test #32:
score: 0
Accepted
time: 6ms
memory: 3880kb
input:
20 10 847175920 439365704 473215562 166583238 625362454 43314630 918168962 805367197 669794952 141443774 551725106 388869509 256958552 6665321 795177606 869847992 903617816 725384164 355322010 664242041 828642286 886444867 100880811 648469308 357482546 290363154 804925144 953197840 600535575 1891279...
output:
2 3 4 6 7 8
result:
ok 6 numbers
Test #33:
score: 0
Accepted
time: 5ms
memory: 3912kb
input:
20 10 1 5 10 16 20 12 8 6 12 9 3 13 11 15 4 1 19 20 13 2 16 7 5 8 9 4 18 3 17 14 6 10 2 17 14 18 15 11 7 19 7 17 10 18 9 11 18 12 14 1 1 17 9 13 10 14 2 4 3 14
output:
1 2 3 4 7 8 9 10
result:
ok 8 numbers
Test #34:
score: 0
Accepted
time: 2ms
memory: 3928kb
input:
20 10 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 1 1 20 20 2 5 4 4 17 6 20 20 6 20 3 3 5 12 14 14
output:
1 2 4 6 8 10
result:
ok 6 numbers
Test #35:
score: 0
Accepted
time: 4ms
memory: 3924kb
input:
20 10 1 20 2 19 3 18 4 17 5 16 6 15 7 14 8 13 9 12 10 11 11 10 12 9 13 8 14 7 15 6 16 5 17 4 18 3 19 2 20 1 1 1 1 20 20 1 20 20 3 17 15 5 12 1 10 6 3 3 18 16
output:
1 4 5 6 7 8 9 10
result:
ok 8 numbers
Test #36:
score: 0
Accepted
time: 3ms
memory: 3972kb
input:
20 10 647485976 833063145 962065068 658413630 729055030 89008090 552814579 367567398 962065068 658413630 57744310 463674984 962065068 658413630 190454651 801934060 57744310 463674984 190454651 801934060 647485976 833063145 962065068 658413630 729055030 89008090 57744310 463674984 57744310 463674984 ...
output:
1 4 6 8 9
result:
ok 5 number(s): "1 4 6 8 9"
Test #37:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
20 10 7 9 6 10 7 9 8 8 7 9 6 9 6 9 7 9 7 10 6 9 6 10 5 9 7 9 6 9 5 10 6 11 5 11 5 10 6 11 7 9 8 8 8 9 8 10 9 8 7 9 7 10 10 8 10 7 10 6 11 8
output:
2 3 5 6
result:
ok 4 number(s): "2 3 5 6"
Test #38:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
20 10 9 7 10 5 9 5 8 8 10 6 9 6 10 6 10 7 9 5 10 6 11 7 9 6 10 5 11 7 9 6 10 7 11 7 9 7 10 6 10 5 8 8 8 9 8 6 9 8 7 9 7 6 10 8 6 7 10 6 5 8
output:
3 4 7 9
result:
ok 4 number(s): "3 4 7 9"
Test #39:
score: 0
Accepted
time: 1ms
memory: 4028kb
input:
20 10 5 10 6 9 8 7 6 11 6 11 6 11 6 9 5 11 5 9 6 11 5 10 5 9 6 11 7 11 5 10 7 10 7 11 7 8 5 11 6 9 8 8 8 9 8 10 7 8 9 9 7 10 6 8 6 7 10 10 5 8
output:
2 3 6 7 8 10
result:
ok 6 numbers
Test #40:
score: 0
Accepted
time: 1ms
memory: 4072kb
input:
20 10 11 7 10 5 8 7 10 7 10 5 10 5 11 7 10 6 9 7 9 7 10 7 11 7 11 7 11 5 11 5 10 7 11 6 7 8 10 7 10 6 8 8 8 9 8 6 7 8 7 7 9 10 6 8 10 7 6 10 11 8
output:
3 5 8 10
result:
ok 4 number(s): "3 5 8 10"
Test #41:
score: 0
Accepted
time: 1ms
memory: 3820kb
input:
20 10 11 5 9 5 11 5 8 9 9 7 9 7 11 5 11 5 11 6 11 6 9 8 9 6 11 6 11 6 9 7 10 6 9 5 11 5 9 5 10 7 8 8 8 7 8 10 9 8 7 7 9 6 6 8 10 9 6 10 11 8
output:
4 6 8 10
result:
ok 4 number(s): "4 6 8 10"
Test #42:
score: 0
Accepted
time: 1ms
memory: 3768kb
input:
20 10 7 11 7 11 7 10 6 9 6 10 7 10 6 10 7 11 7 9 7 11 8 9 7 9 5 9 6 10 5 9 7 11 9 8 5 10 5 10 6 10 8 8 8 7 8 6 9 8 7 9 9 10 10 8 6 9 10 10 5 8
output:
5 6 8 10
result:
ok 4 number(s): "5 6 8 10"
Test #43:
score: 0
Accepted
time: 1ms
memory: 3800kb
input:
20 10 8 7 7 11 6 10 6 9 7 11 5 11 7 11 5 11 6 10 5 9 6 10 7 9 5 9 7 10 7 10 5 10 7 10 6 11 7 8 7 11 8 8 8 7 8 6 9 8 7 9 7 6 10 8 10 7 6 10 11 8
output:
1 5 9
result:
ok 3 number(s): "1 5 9"
Test #44:
score: 0
Accepted
time: 1ms
memory: 3764kb
input:
20 10 9 8 9 7 11 5 11 6 9 7 9 7 10 6 10 6 10 7 10 7 9 5 11 5 10 6 9 6 10 6 10 5 10 6 11 6 11 5 8 9 8 8 8 9 8 6 9 8 9 7 9 6 6 8 6 9 10 6 5 8
output:
1 3 4 5 6 9
result:
ok 6 numbers
Test #45:
score: 0
Accepted
time: 2ms
memory: 3796kb
input:
20 10 9 7 10 7 10 5 8 9 9 8 5 11 7 10 5 10 6 10 7 9 6 11 5 11 7 10 6 10 7 10 6 11 6 11 6 11 6 11 7 10 8 8 8 9 8 6 7 8 9 7 9 6 6 8 10 7 6 10 11 8
output:
1 2 4 5 7 8 9
result:
ok 7 numbers
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #46:
score: 0
Time Limit Exceeded
input:
1500 10 401134743 898594342 739681625 898594342 842492194 569404274 888451796 685104441 945772067 221545383 142276409 691220027 618847410 643831161 16003964 98459610 713370318 64857580 724642432 4634850 273681220 854797105 989430408 833800077 514271483 906536506 13011218 464186337 807512695 78088298...
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%