QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#424856 | #4270. Double Attendance | Romeo | 0 | 6ms | 13388kb | C++17 | 1.9kb | 2024-05-29 19:01:50 | 2024-05-29 19:01:50 |
Judging History
answer
#include <iostream>
#include <algorithm>
#include <cstring>
typedef long long ll;
const int N = 6e5;
const int INF = 0x3f3f3f3f;
inline int read() {int x; return scanf("%d", &x), x;}
int n[2], m;
int dp[N + 5][2][2];
struct node
{
int l, r;
bool operator < (const node &t) const {return l < t.l;}
bool operator < (const int &t) const {return r < t;}
} block[2][N + 5];
inline int find(int type, int pos)
{
int t = std :: lower_bound(block[type] + 1, block[type] + n[type] + 1, pos) - block[type];
return block[type][t].l <= pos ? t : 0;
}
inline int next(int type, int pos)
{
int t = std :: lower_bound(block[type] + 1, block[type] + n[type] + 1, pos) - block[type];
return t + (block[type][t].l <= pos);
}
inline void modify(int &x, int y) {x = std :: min(x, y);}
int main()
{
n[0] = read() + 1, n[1] = read() + 1, m = read();
for (int i = 1; i < n[0]; i ++ ) block[0][i] = /* */ {read(), read() - 1}; block[0][n[0]] = /* */ {INF, INF}; std :: sort(block[0] + 1, block[0] + n[0] + 1);
for (int i = 1; i < n[1]; i ++ ) block[1][i] = /* */ {read(), read() - 1}; block[1][n[1]] = /* */ {INF, INF}; std :: sort(block[1] + 1, block[1] + n[1] + 1);
std :: memset(dp, 0x3f, sizeof dp);
dp[!block[0][1].l][0][0] = 0;
int res = 0;
for (int i = 0; i <= n[0] + n[1]; i ++ )
for (int cas = 0; cas <= 1; cas ++ )
for (int j = 0; j <= 1; j ++ )
for (int k = 0; k <= 1; k ++ )
{
int tim = dp[i][j][k];
if (dp[i][j][k] >= INF) continue;
int pos = find(j, tim), across = find(j ^ 1, tim + m), after = next(j, tim);
modify(dp[i + (across && !k)][j ^ 1][find(j, tim + 2 * m) == pos], tim + m);
modify(dp[i + 1][j][find(j, block[j][after].l + m) == across], block[j][after].l);
}
for (int i = n[0] + n[1] - 2; i >= 0; i -- ) if (std :: min({dp[i][0][0], dp[i][0][1], dp[i][1][0], dp[i][1][1]}) < INF) return printf("%d", i), 0;
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 13312kb
input:
3 1 8 10 20 100 101 20 21 15 25
output:
3
result:
ok single line: '3'
Test #2:
score: 5
Accepted
time: 0ms
memory: 13356kb
input:
1 5 3 1 100 1 2 2 3 3 4 4 5 5 6
output:
4
result:
ok single line: '4'
Test #3:
score: 5
Accepted
time: 0ms
memory: 13224kb
input:
10 10 5 4 9 43 48 69 70 70 72 52 67 75 83 100 103 103 1501 10 27 28 40 5 7 27 29 30 39 40 42 42 45 67 80 0 5 45 59 10 20 22 23
output:
18
result:
ok single line: '18'
Test #4:
score: 5
Accepted
time: 0ms
memory: 13216kb
input:
1 1 1 0 1 0 1
output:
1
result:
ok single line: '1'
Test #5:
score: 5
Accepted
time: 0ms
memory: 13220kb
input:
1 10 2 1 2000 4 5 10 11 7 8 3 4 9 10 1 2 2 3 8 9 6 7 5 6
output:
10
result:
ok single line: '10'
Test #6:
score: 5
Accepted
time: 0ms
memory: 13312kb
input:
10 10 90 1440 1620 0 180 1080 1260 900 1080 180 360 720 900 540 720 360 540 1620 1800 1260 1440 1170 1350 990 1170 1530 1710 1350 1530 90 270 450 630 270 450 630 810 810 990 1710 1890
output:
20
result:
ok single line: '20'
Test #7:
score: 5
Accepted
time: 4ms
memory: 13304kb
input:
10 10 90 1080 1260 1440 1620 900 1080 1620 1800 180 360 360 540 540 720 1800 1980 1260 1440 720 900 90 270 1710 1890 810 990 1170 1350 1530 1710 630 810 1350 1530 990 1170 450 630 270 450
output:
20
result:
ok single line: '20'
Test #8:
score: 5
Accepted
time: 5ms
memory: 13356kb
input:
10 10 166 1 2 664 996 332 664 1660 1992 0 1 1328 1660 996 1328 3 4 2 3 4 5 333 334 1494 1826 498 830 1162 1494 334 335 336 337 0 332 830 1162 335 336 332 333
output:
20
result:
ok single line: '20'
Test #9:
score: 5
Accepted
time: 0ms
memory: 13172kb
input:
10 10 166 2 3 0 1 3 4 1328 1660 1999 2000 996 1328 1 2 332 664 4 5 664 996 334 335 335 336 333 334 1162 1494 0 332 498 830 336 337 830 1162 332 333 1999 2000
output:
19
result:
ok single line: '19'
Test #10:
score: 5
Accepted
time: 0ms
memory: 13172kb
input:
10 10 1 1607 1721 327 413 222 264 1744 1746 35 50 619 766 995 1127 1421 1541 1236 1294 984 995 626 1122 1313 1386 65 141 1394 1428 1553 1764 1766 1990 1551 1552 465 531 1500 1531 623 625
output:
20
result:
ok single line: '20'
Test #11:
score: 5
Accepted
time: 0ms
memory: 13296kb
input:
10 10 1000000000 664 1247 157 183 1975 1986 1289 1374 1448 1461 233 326 1888 1913 183 194 1927 1933 1499 1672 1138 1387 402 652 266 396 1439 1452 1954 1956 684 737 1700 1887 1576 1678 1473 1485 886 1004
output:
10
result:
ok single line: '10'
Test #12:
score: 5
Accepted
time: 2ms
memory: 13360kb
input:
10 10 3 786 792 1395 1579 1348 1371 303 371 430 431 1331 1343 813 1050 1833 1853 654 706 622 634 237 302 1261 1266 49 216 1514 1524 1524 1607 1004 1018 748 918 1020 1141 1967 1994 1710 1735
output:
20
result:
ok single line: '20'
Test #13:
score: 5
Accepted
time: 5ms
memory: 13180kb
input:
10 10 4 82 206 370 769 1086 1131 267 330 836 984 995 1052 778 805 1880 1956 1956 1999 1531 1761 1687 1730 1879 1968 694 710 441 674 738 1302 1734 1737 1357 1365 1372 1604 1606 1672 722 726
output:
20
result:
ok single line: '20'
Test #14:
score: 5
Accepted
time: 0ms
memory: 13312kb
input:
10 10 9 1667 1724 266 375 1736 1936 1312 1659 858 886 442 708 193 198 1127 1244 383 428 935 1021 614 628 1797 1832 199 218 229 268 386 404 413 587 962 1248 814 878 1462 1732 1420 1424
output:
20
result:
ok single line: '20'
Test #15:
score: 5
Accepted
time: 0ms
memory: 13320kb
input:
10 10 16 14 88 1638 1644 645 970 1218 1232 1401 1589 1972 1994 1657 1721 1145 1188 1243 1246 179 244 1925 1958 355 433 706 832 564 587 12 270 1541 1728 1499 1529 294 348 1160 1205 1004 1032
output:
20
result:
ok single line: '20'
Test #16:
score: 5
Accepted
time: 0ms
memory: 13316kb
input:
10 10 64 998 1233 1868 1888 1898 1943 1811 1818 243 292 185 202 205 211 342 454 1269 1313 970 973 770 1192 1424 1435 710 715 60 74 77 250 1992 1998 715 758 1393 1397 1523 1695 359 439
output:
20
result:
ok single line: '20'
Test #17:
score: 0
Wrong Answer
time: 5ms
memory: 13316kb
input:
10 10 31 1755 1831 1513 1514 559 565 1557 1727 1891 1997 56 159 527 544 1745 1749 572 1106 483 504 1789 1824 1306 1439 1680 1789 1490 1528 1089 1144 832 1010 18 306 813 820 598 757 1184 1229
output:
20
result:
wrong answer 1st lines differ - expected: '19', found: '20'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #104:
score: 6
Accepted
time: 2ms
memory: 13352kb
input:
1 1 1 0 1 0 1
output:
1
result:
ok single line: '1'
Test #105:
score: 6
Accepted
time: 0ms
memory: 13336kb
input:
1 2000 2 999999996 1000000000 336 337 502 503 1906 1907 963 964 1351 1352 1795 1796 1510 1511 304 305 1930 1931 1735 1736 1469 1470 338 339 813 814 182 183 209 210 321 322 849 850 721 722 394 395 889 890 1758 1759 1440 1441 560 561 1470 1471 1916 1917 793 794 1366 1367 158 159 1602 1603 214 215 1119...
output:
2000
result:
ok single line: '2000'
Test #106:
score: 6
Accepted
time: 0ms
memory: 13384kb
input:
2000 2000 249875 608195750 608695500 88455750 88955500 579210250 579710000 817091250 817591000 527736000 528235750 52473750 52973500 89955000 90454750 184407750 184907500 668165750 668665500 24487750 24987500 466266750 466766500 471764000 472263750 212393750 212893500 250874500 251374250 939530000 9...
output:
4000
result:
ok single line: '4000'
Test #107:
score: 6
Accepted
time: 0ms
memory: 13256kb
input:
2000 2000 249875 965017250 965517000 73963000 74462750 242878500 243378250 148925500 149425250 747126250 747626000 384307750 384807500 655172250 655672000 278360750 278860500 899050250 899550000 496251750 496751500 92953500 93453250 677661000 678160750 828085750 828585500 297351250 297851000 5887055...
output:
4000
result:
ok single line: '4000'
Test #108:
score: 6
Accepted
time: 0ms
memory: 13264kb
input:
2000 2000 499500 428 429 764235000 765234000 511488000 512487000 291 292 585414000 586413000 127 128 819 820 727 728 233766000 234765000 643 644 234 235 326 327 432 433 218781000 219780000 10989000 11988000 805194000 806193000 283716000 284715000 965034000 966033000 632367000 633366000 824 825 454 4...
output:
4000
result:
ok single line: '4000'
Test #109:
score: 6
Accepted
time: 0ms
memory: 13184kb
input:
2000 2000 499500 175 176 766233000 767232000 230 231 925 926 844 845 681318000 682317000 48951000 49950000 757 758 266 267 438561000 439560000 262737000 263736000 813 814 915084000 916083000 485514000 486513000 214785000 215784000 532467000 533466000 25 26 41958000 42957000 534 535 331 332 53 54 732...
output:
3999
result:
ok single line: '3999'
Test #110:
score: 6
Accepted
time: 3ms
memory: 13176kb
input:
2000 2000 1 97918740 97918742 612788646 612788648 709014683 709014684 550596486 550596488 611820813 611820815 742133170 742133172 999593290 999593292 65695562 65695563 984598976 984598977 285428771 285428773 334881813 334881814 751309389 751309390 635034524 635034526 202056719 202056720 472216430 47...
output:
4000
result:
ok single line: '4000'
Test #111:
score: 6
Accepted
time: 0ms
memory: 13248kb
input:
2000 2000 1000000000 762582513 763402869 685982674 685994777 607586653 607621748 725505868 725606928 287661547 287711487 961278566 961422544 282891861 282922769 388240582 388471546 305173664 305545845 17696180 17939334 267223086 267237726 251362344 251735629 957622587 957813570 321979347 321992100 7...
output:
2000
result:
ok single line: '2000'
Test #112:
score: 6
Accepted
time: 6ms
memory: 13316kb
input:
2000 2000 1000000000 675 676 1250 1251 1565 1566 211 212 951 952 250 251 1975 1976 775 776 795 796 85 86 212 213 293 294 1970 1971 627 628 1945 1946 688 689 1050 1051 223 224 288 289 476 477 137 138 613 614 1400 1401 1087 1088 801 802 734 735 1112 1113 51 52 1127 1128 546 547 881 882 276 277 680 681...
output:
2000
result:
ok single line: '2000'
Test #113:
score: 6
Accepted
time: 0ms
memory: 13376kb
input:
2000 2000 2000 683 684 170 171 1005 1006 1612 1613 330 331 280 281 1340 1341 1083 1084 355 356 1603 1604 1001 1002 873 874 1520 1521 1657 1658 1827 1828 1868 1869 655 656 1981 1982 184 185 900 901 1917 1918 1096 1097 956 957 987 988 536 537 921 922 317 318 869 870 1095 1096 1684 1685 762 763 1896 18...
output:
2000
result:
ok single line: '2000'
Test #114:
score: 6
Accepted
time: 0ms
memory: 13376kb
input:
89 1537 3 1761 1764 1885 1887 1489 1490 1523 1528 1491 1494 1204 1206 288 293 1433 1439 233 235 1007 1009 1630 1635 1297 1301 359 363 1559 1561 1918 1922 1160 1161 1374 1377 418 420 248 252 1826 1831 1051 1053 720 722 276 279 1516 1522 1638 1639 28 34 1392 1394 1867 1869 1030 1035 961 964 951 954 56...
output:
1538
result:
ok single line: '1538'
Test #115:
score: 6
Accepted
time: 0ms
memory: 13380kb
input:
1530 1057 6 333 334 1671 1672 855 856 237 238 429 430 172 173 1721 1722 784 785 485 486 771 772 1563 1564 781 784 852 854 510 511 754 755 1640 1641 1748 1749 152 153 1286 1287 1765 1766 483 484 1374 1375 1435 1436 1081 1082 1960 1961 1512 1513 1001 1002 1287 1288 1737 1738 1213 1214 901 902 271 272 ...
output:
1530
result:
ok single line: '1530'
Test #116:
score: 6
Accepted
time: 3ms
memory: 13232kb
input:
1852 95 2 1686 1687 1089 1090 1406 1407 1703 1704 270 271 124 125 1656 1657 1467 1468 1244 1245 198 199 720 721 240 241 954 955 1617 1618 1576 1577 693 694 887 888 1875 1876 65 66 210 211 972 973 60 61 1977 1978 1747 1748 88 89 1571 1572 1913 1914 959 960 978 979 1592 1593 160 161 911 912 1923 1924 ...
output:
1852
result:
ok single line: '1852'
Test #117:
score: 6
Accepted
time: 0ms
memory: 13324kb
input:
2000 2000 8 113542287 113542302 390186210 390186213 767610940 767610945 166969613 166969625 576186044 576186049 900919537 900919544 65847079 65847093 914274569 914274570 717871869 717871873 446375619 446375623 411070467 411070470 118697002 118697012 686550784 686550796 825791725 825791731 986657892 ...
output:
4000
result:
ok single line: '4000'
Test #118:
score: 6
Accepted
time: 4ms
memory: 13388kb
input:
2000 2000 5 323112971 323112977 625095129 625095132 724765420 724765421 63941016 63941019 914151487 914151492 984437587 984437595 208379851 208379858 839949614 839949623 928366669 928366671 561458859 561458867 972589960 972589964 576223356 576223364 739171385 739171390 663662925 663662932 525889027 ...
output:
4000
result:
ok single line: '4000'
Test #119:
score: 6
Accepted
time: 4ms
memory: 13184kb
input:
2000 2000 6 298171660 298171662 490725349 490725356 36304805 36304811 207802050 207802060 837587473 837587479 987183666 987183676 560955022 560955034 287590452 287590463 694565254 694565264 859529266 859529272 541494910 541494922 771349806 771349812 225787473 225787476 648584932 648584944 905255077 ...
output:
4000
result:
ok single line: '4000'
Test #120:
score: 6
Accepted
time: 3ms
memory: 13276kb
input:
1641 1376 22 377 378 697 698 693 694 210 211 1214 1216 1345 1346 846 847 1532 1533 1935 1937 1069 1070 1597 1598 318 319 1066 1067 886 887 1302 1303 1103 1105 631 632 1787 1788 1063 1064 1152 1154 227 228 351 352 1718 1719 754 755 238 239 651 652 704 705 601 602 1332 1333 1945 1946 421 422 1392 1393...
output:
1641
result:
ok single line: '1641'
Test #121:
score: 6
Accepted
time: 2ms
memory: 13372kb
input:
718 741 39 1263 1273 1019 1020 1202 1205 1105 1106 1194 1195 459 463 548 550 1821 1825 1853 1854 1664 1665 831 832 26 27 705 706 1832 1833 1466 1467 1438 1439 1841 1842 590 591 1981 1983 1310 1314 1850 1853 1978 1980 1948 1949 993 994 743 746 702 704 1748 1751 956 957 536 539 1694 1696 653 654 54 55...
output:
735
result:
ok single line: '735'
Test #122:
score: 6
Accepted
time: 3ms
memory: 13376kb
input:
1375 1578 67 427 428 14 15 1981 1982 1983 1984 1865 1866 1425 1426 1944 1945 1796 1798 1045 1046 705 706 870 871 184 185 1817 1818 591 592 1710 1711 1132 1133 782 783 902 903 1805 1806 1438 1439 1508 1510 620 621 1832 1833 594 596 1471 1472 645 646 432 434 1680 1681 8 9 1318 1319 1543 1544 977 978 1...
output:
1532
result:
ok single line: '1532'
Test #123:
score: 0
Wrong Answer
time: 3ms
memory: 13276kb
input:
2000 2000 22 341868816 341868843 367155688 367155695 135493529 135493570 659841251 659841280 765819862 765819872 784722731 784722769 141544674 141544697 616625335 616625350 476905250 476905273 242349445 242349486 939296167 939296190 296381442 296381478 528751822 528751862 608293329 608293356 5822529...
output:
3999
result:
wrong answer 1st lines differ - expected: '4000', found: '3999'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%