QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#166745 | #7069. Farm | ucup-team004# | AC ✓ | 157ms | 11796kb | C++20 | 3.0kb | 2023-09-06 17:34:13 | 2023-09-06 17:34:13 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m;
std::cin >> n >> m;
std::vector<int> a(m), b(m), c(m);
for (int i = 0; i < m; i++) {
std::cin >> a[i] >> b[i] >> c[i];
a[i]--, b[i]--;
}
int q;
std::cin >> q;
std::vector<int> u(q), v(q);
for (int i = 0; i < q; i++) {
std::cin >> u[i] >> v[i];
u[i]--, v[i]--;
}
std::vector<int> f(n);
std::iota(f.begin(), f.end(), 0);
auto find = [&](int x) {
while (f[x] != x) {
x = f[x] = f[f[x]];
}
return x;
};
auto merge = [&](int x, int y) -> bool {
x = find(x);
y = find(y);
if (x == y) {
return false;
}
f[y] = x;
return true;
};
int ans = 1E9;
std::vector<int> p(m);
std::iota(p.begin(), p.end(), 0);
std::sort(p.begin(), p.end(),
[&](int i, int j) {
return c[i] < c[j];
});
for (int i = 0; i < q; i++) {
merge(a[u[i]], b[u[i]]);
merge(a[v[i]], b[v[i]]);
}
std::vector<bool> use(m);
int tot = 0;
for (auto j : p) {
if (merge(a[j], b[j])) {
tot += c[j];
use[j] = true;
}
}
for (int i = 0; i < n; i++) {
if (find(i) != find(0)) {
std::cout << -1 << "\n";
return 0;
}
}
std::iota(f.begin(), f.end(), 0);
for (auto j : p) {
if (use[j]) {
merge(a[j], b[j]);
}
}
std::vector<int> id(n, -1);
int cnt = 0;
for (int i = 0; i < n; i++) {
if (id[find(i)] == -1) {
id[find(i)] = cnt++;
}
id[i] = id[find(i)];
}
f.resize(cnt);
std::iota(f.begin(), f.end(), 0);
std::vector<int> r;
for (int i = 0; i < m; i++) {
int j = p[i];
if (merge(id[a[j]], id[b[j]])) {
r.push_back(j);
}
}
use.assign(m, false);
for (int mask = 0; mask < (1 << q); mask++) {
int res = tot;
std::iota(f.begin(), f.end(), 0);
for (int i = 0; i < q; i++) {
int j;
if (mask >> i & 1) {
j = u[i];
} else {
j = v[i];
}
if (!use[j]) {
use[j] = true;
merge(id[a[j]], id[b[j]]);
res += c[j];
}
}
for (auto j : r) {
if (merge(id[a[j]], id[b[j]])) {
res += c[j];
}
}
for (int i = 0; i < q; i++) {
int j;
if (mask >> i & 1) {
j = u[i];
} else {
j = v[i];
}
use[j] = false;
}
ans = std::min(ans, res);
}
std::cout << ans << "\n";
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3492kb
input:
4 6 1 1 2 2 4 3 1 1 4 2 4 4 3 2 4 1 3 4 1 1 2
output:
11
result:
ok single line: '11'
Test #2:
score: 0
Accepted
time: 101ms
memory: 11484kb
input:
100000 500000 2516 13348 191 37713 25720 216 41568 13765 877 2116 27917 895 76904 65435 37 73053 24687 44 97127 44338 700 2251 85769 378 95166 20208 42 59303 57463 158 26863 18030 31 58613 6818 2 15455 18106 254 3232 13720 610 85677 16778 650 25618 72746 813 80365 162 47 10930 7403 645 79272 54568 6...
output:
-1
result:
ok single line: '-1'
Test #3:
score: 0
Accepted
time: 117ms
memory: 11708kb
input:
100000 500000 34497 87538 658 69862 2776 861 93620 16992 904 77910 81200 149 83935 83752 880 17602 75791 259 85887 53289 710 4200 79358 181 8518 19264 737 94665 47462 822 50632 51994 143 55224 59127 656 615 92858 150 48450 9465 58 35713 45287 140 64861 32248 517 70296 45113 153 11189 90316 809 40673...
output:
12148224
result:
ok single line: '12148224'
Test #4:
score: 0
Accepted
time: 84ms
memory: 10964kb
input:
1 500000 1 1 963 1 1 349 1 1 157 1 1 6 1 1 312 1 1 377 1 1 783 1 1 42 1 1 18 1 1 327 1 1 499 1 1 824 1 1 343 1 1 798 1 1 193 1 1 667 1 1 378 1 1 641 1 1 692 1 1 622 1 1 584 1 1 590 1 1 324 1 1 858 1 1 914 1 1 601 1 1 734 1 1 61 1 1 559 1 1 681 1 1 825 1 1 888 1 1 585 1 1 55 1 1 818 1 1 190 1 1 278 1...
output:
1605
result:
ok single line: '1605'
Test #5:
score: 0
Accepted
time: 106ms
memory: 10896kb
input:
5 500000 5 1 817 2 1 273 3 5 674 1 5 15 5 2 872 3 4 728 3 2 807 5 3 28 2 5 96 1 5 100 4 2 224 4 4 980 5 5 727 2 2 520 4 1 29 2 1 142 4 2 963 4 4 118 4 4 615 4 3 719 5 3 200 5 2 746 4 2 68 5 4 859 1 3 182 3 4 286 3 1 229 4 1 895 2 1 730 1 2 622 2 4 913 2 1 697 5 5 130 4 5 507 5 2 425 2 4 716 2 1 884 ...
output:
3097
result:
ok single line: '3097'
Test #6:
score: 0
Accepted
time: 100ms
memory: 11000kb
input:
10 500000 3 8 138 10 7 593 4 3 8 7 5 516 10 4 49 3 8 601 6 7 481 8 5 429 6 4 241 1 6 504 6 2 252 7 1 656 5 1 350 5 9 485 7 8 669 5 8 630 9 9 324 1 3 427 1 2 309 5 10 236 4 6 926 8 7 34 5 1 336 7 5 581 4 5 228 10 3 909 2 9 726 4 2 444 10 1 55 1 2 244 5 8 261 2 7 556 10 2 165 6 3 657 7 5 580 7 1 827 1...
output:
1533
result:
ok single line: '1533'
Test #7:
score: 0
Accepted
time: 107ms
memory: 10916kb
input:
100 500000 10 46 133 79 13 987 26 2 743 8 47 390 79 19 737 11 64 197 16 65 207 73 9 944 77 58 841 50 3 245 81 100 293 21 12 713 60 65 155 89 87 865 88 67 278 9 15 920 46 52 704 26 26 731 44 98 525 20 68 346 14 95 932 84 19 697 41 21 290 83 24 750 3 71 369 54 80 396 20 70 208 25 55 456 40 22 938 90 1...
output:
2209
result:
ok single line: '2209'
Test #8:
score: 0
Accepted
time: 14ms
memory: 3572kb
input:
1000 10000 186 620 701 360 808 963 181 434 297 873 511 550 949 641 670 36 318 299 635 543 56 284 519 439 816 900 877 84 189 141 393 679 222 169 669 974 826 703 651 201 659 644 1000 388 69 263 104 625 278 386 526 35 262 697 776 871 702 407 153 783 130 857 596 78 140 46 391 173 636 8 419 879 804 197 7...
output:
60430
result:
ok single line: '60430'
Test #9:
score: 0
Accepted
time: 32ms
memory: 4536kb
input:
1000 100000 64 501 272 114 900 116 858 404 897 442 351 101 232 419 117 803 929 38 451 759 769 39 387 881 906 961 105 82 652 795 657 958 636 55 986 248 623 912 446 326 513 863 886 207 977 908 104 591 932 132 666 239 166 495 772 97 650 22 485 978 584 308 526 548 70 979 359 993 226 462 881 398 134 222 ...
output:
7739
result:
ok single line: '7739'
Test #10:
score: 0
Accepted
time: 106ms
memory: 10964kb
input:
1000 500000 869 767 467 831 564 631 555 269 463 490 912 126 978 305 712 940 979 160 339 21 141 511 430 140 80 937 427 286 983 680 880 302 160 143 691 411 360 439 853 797 37 867 804 299 98 651 278 495 590 213 229 768 741 351 286 343 573 935 641 155 747 707 468 653 148 489 936 284 780 737 138 947 978 ...
output:
3777
result:
ok single line: '3777'
Test #11:
score: 0
Accepted
time: 102ms
memory: 10952kb
input:
10000 500000 831 9646 869 7698 1808 110 1692 824 716 1949 126 562 7824 2747 105 2753 2203 63 6720 5207 251 2425 3114 828 1073 5865 688 5748 7968 709 2843 5863 162 239 1523 688 6219 4445 289 5919 7428 216 4462 4775 865 2397 3242 384 459 5263 590 6806 5824 442 4834 3960 398 2802 1664 722 5875 6346 526...
output:
127714
result:
ok single line: '127714'
Test #12:
score: 0
Accepted
time: 89ms
memory: 11504kb
input:
100000 500000 99571 415 842 88646 76834 340 7335 47388 939 29506 84999 845 6493 2762 484 61459 21964 192 48115 21757 648 47229 69919 198 31212 80973 812 41884 81592 730 22948 57810 760 51775 97910 854 75732 989 810 9540 13078 465 76070 7833 486 66356 54068 56 24313 31298 9 11873 17766 532 66456 7046...
output:
-1
result:
ok single line: '-1'
Test #13:
score: 0
Accepted
time: 118ms
memory: 11744kb
input:
100000 500000 12797 57359 174 19769 96152 455 96587 35545 660 45759 66401 996 82264 92296 828 49738 92800 886 6264 91012 156 8370 26551 923 47840 28952 983 86182 40818 337 36097 67441 984 16458 53827 896 72519 77300 503 44464 19421 386 78386 12255 967 72406 29902 239 17363 27044 112 11359 42336 780 ...
output:
12108785
result:
ok single line: '12108785'
Test #14:
score: 0
Accepted
time: 17ms
memory: 3604kb
input:
1000 10000 224 608 374 666 376 667 338 310 763 941 335 581 29 148 960 715 103 365 229 965 998 761 784 956 278 173 523 943 668 997 922 959 17 785 873 618 77 715 587 249 424 358 411 822 724 493 60 375 702 629 182 106 905 43 609 830 323 353 290 814 69 512 391 102 982 797 902 381 935 1 124 858 318 239 9...
output:
62175
result:
ok single line: '62175'
Test #15:
score: 0
Accepted
time: 38ms
memory: 4552kb
input:
1000 100000 879 175 809 383 382 795 991 410 883 737 145 82 468 846 91 933 318 620 710 893 41 15 501 197 724 471 114 293 108 9 192 633 606 984 107 214 179 862 512 488 493 970 766 83 832 502 955 852 835 512 298 395 311 512 59 314 736 904 695 1000 214 580 187 565 431 454 567 220 329 402 62 428 712 382 ...
output:
8023
result:
ok single line: '8023'
Test #16:
score: 0
Accepted
time: 108ms
memory: 10996kb
input:
1000 500000 480 625 239 545 57 466 571 149 292 571 849 18 721 961 130 328 284 100 198 563 318 387 597 144 170 582 102 500 793 466 836 453 294 121 539 94 323 767 888 512 379 406 935 244 45 459 74 617 711 494 257 860 113 14 292 115 646 787 283 209 143 34 991 686 63 365 6 132 975 96 754 739 572 789 963...
output:
4501
result:
ok single line: '4501'
Test #17:
score: 0
Accepted
time: 107ms
memory: 10996kb
input:
10000 500000 1184 3108 786 7191 748 754 5726 987 56 1471 8722 327 6546 1456 69 7616 9880 350 9632 289 574 3021 4111 386 2148 374 943 8652 7726 109 6210 302 282 6331 6404 419 6317 5277 482 4818 7055 227 8438 661 890 1610 5069 522 3207 3171 984 5293 3712 817 7326 9628 639 31 5689 209 4030 9448 749 556...
output:
126618
result:
ok single line: '126618'
Test #18:
score: 0
Accepted
time: 109ms
memory: 11500kb
input:
100000 500000 24389 38801 388 68266 67993 450 21673 73700 289 40603 55687 560 48860 19420 464 31513 52943 501 32436 90543 307 37182 68965 918 49470 88373 336 73085 92886 403 46163 74568 377 85055 70697 807 34488 49121 736 92860 51095 864 10076 48017 783 55197 1449 984 84685 37278 613 31985 15952 148...
output:
-1
result:
ok single line: '-1'
Test #19:
score: 0
Accepted
time: 123ms
memory: 11756kb
input:
100000 500000 36395 44833 733 19257 62963 582 4221 94578 570 61950 32455 749 98164 17289 237 86685 26360 787 78779 55624 985 81765 83293 312 64655 24186 861 87154 10499 859 58502 23298 974 99932 85595 574 21762 48036 977 69375 98183 369 76024 41555 784 24746 61062 773 74076 89563 228 26923 49725 853...
output:
12019772
result:
ok single line: '12019772'
Test #20:
score: 0
Accepted
time: 24ms
memory: 3660kb
input:
1000 10000 815 438 261 263 620 464 492 833 701 43 3 724 73 761 333 670 501 753 812 966 627 382 124 282 863 619 664 288 531 848 855 456 954 309 995 497 747 977 530 684 174 966 168 180 875 937 710 440 773 806 727 348 746 422 920 865 85 812 727 767 396 332 506 636 626 160 32 758 829 344 193 54 714 691 ...
output:
60511
result:
ok single line: '60511'
Test #21:
score: 0
Accepted
time: 26ms
memory: 4612kb
input:
1000 100000 278 738 442 462 916 320 80 75 699 106 57 10 416 398 523 76 333 144 495 367 533 882 152 713 447 550 887 205 220 220 834 958 32 152 188 733 376 250 317 408 818 791 91 142 320 252 118 50 982 88 184 462 69 140 880 965 723 182 517 565 737 442 336 905 75 915 553 465 753 471 825 407 393 834 809...
output:
10574
result:
ok single line: '10574'
Test #22:
score: 0
Accepted
time: 119ms
memory: 10884kb
input:
1000 500000 140 811 393 232 53 383 517 252 530 726 980 985 42 796 633 732 738 89 839 336 983 994 896 171 293 405 769 847 643 57 251 898 229 844 196 110 73 995 428 689 162 845 441 854 376 712 419 11 398 499 168 833 507 154 697 559 18 622 411 511 594 810 912 616 262 79 483 418 917 217 864 261 179 231 ...
output:
5072
result:
ok single line: '5072'
Test #23:
score: 0
Accepted
time: 116ms
memory: 10964kb
input:
10000 500000 3548 4998 748 773 1447 567 4887 1282 294 5330 2854 293 8867 9780 275 6427 2334 339 6977 6870 535 9628 5219 900 1863 8493 121 9998 1576 892 8626 9939 513 9862 2253 434 5771 609 319 2699 5350 563 1944 5567 325 7160 7709 619 597 8880 600 5266 6811 662 7219 776 819 9866 1009 807 5185 1520 6...
output:
126914
result:
ok single line: '126914'
Test #24:
score: 0
Accepted
time: 98ms
memory: 11420kb
input:
100000 500000 50847 99096 626 79421 12125 312 19803 7831 791 34006 75437 549 80797 6002 426 45416 20946 528 14855 5559 486 42721 22815 701 76077 96521 975 23512 4543 418 37104 31388 918 12936 38993 142 27994 41324 875 86922 6440 962 44763 53726 991 37874 91843 828 33090 58426 280 24524 11273 450 823...
output:
-1
result:
ok single line: '-1'
Test #25:
score: 0
Accepted
time: 114ms
memory: 11788kb
input:
100000 500000 38677 51452 46 92797 50792 76 27756 67517 781 83039 90966 713 1856 20153 907 80757 72883 862 59510 23882 707 92401 44326 755 80746 84793 854 65465 91796 262 22070 44712 114 11696 4616 328 6882 57057 484 88644 59844 766 74636 28862 38 12409 13641 609 90106 95866 316 35766 81123 57 99518...
output:
12083121
result:
ok single line: '12083121'
Test #26:
score: 0
Accepted
time: 29ms
memory: 3656kb
input:
1000 10000 986 200 591 474 282 554 743 141 189 126 222 221 16 411 529 40 332 733 307 830 520 332 398 854 943 816 893 952 240 74 878 82 232 940 927 885 990 52 267 559 41 297 995 378 278 690 311 631 742 462 133 533 933 865 592 616 343 333 551 483 450 749 409 718 564 711 169 83 386 420 503 629 10 707 8...
output:
61590
result:
ok single line: '61590'
Test #27:
score: 0
Accepted
time: 52ms
memory: 4524kb
input:
1000 100000 481 458 905 251 681 173 302 615 954 420 419 292 987 598 982 80 490 663 163 11 598 625 871 551 627 707 15 246 406 856 492 397 346 677 774 323 843 625 658 845 86 46 191 464 198 997 492 967 888 353 357 432 283 964 445 548 930 976 503 726 408 311 745 714 909 889 293 448 601 618 470 152 424 8...
output:
12088
result:
ok single line: '12088'
Test #28:
score: 0
Accepted
time: 113ms
memory: 10892kb
input:
1000 500000 596 385 935 80 632 98 180 250 325 42 94 552 336 815 581 330 795 629 908 797 595 866 514 50 963 521 12 662 23 111 161 929 890 697 5 703 752 908 543 202 980 892 10 21 260 654 456 10 584 941 322 278 222 888 281 896 433 418 833 789 341 146 416 439 885 953 348 593 998 630 738 901 473 429 616 ...
output:
5804
result:
ok single line: '5804'
Test #29:
score: 0
Accepted
time: 145ms
memory: 10880kb
input:
10000 500000 4474 7787 610 6324 7006 339 5439 5095 784 6743 4531 398 1777 3209 394 7850 8506 715 6094 5908 213 9549 715 43 1186 8885 770 7647 4052 266 1722 9634 986 7529 9578 562 8054 1937 369 2889 8817 38 8783 4981 109 4913 1641 880 826 494 848 5360 8313 844 9706 2720 300 4737 5888 110 7980 9396 72...
output:
129398
result:
ok single line: '129398'
Test #30:
score: 0
Accepted
time: 108ms
memory: 11412kb
input:
100000 500000 48490 86020 557 61197 19482 396 33255 32805 88 65505 37852 977 48966 61777 120 85169 56075 144 90043 35530 825 30421 6905 999 52054 65691 562 71316 26811 873 35699 65090 960 65515 44636 871 32966 21534 553 91194 29795 144 49025 4219 42 31189 9762 473 18664 39835 355 69674 4096 23 18168...
output:
-1
result:
ok single line: '-1'
Test #31:
score: 0
Accepted
time: 142ms
memory: 11792kb
input:
100000 500000 46727 28775 202 52053 19805 908 42206 66421 42 11807 68322 241 54079 58881 115 33613 26240 784 75486 17712 895 73757 13254 214 89360 49855 569 17750 70700 887 45612 18684 446 31458 82643 225 4000 23138 514 6638 13503 725 65111 36789 43 18628 7028 784 65609 36670 82 14632 79089 410 2668...
output:
12036530
result:
ok single line: '12036530'
Test #32:
score: 0
Accepted
time: 12ms
memory: 3592kb
input:
1000 10000 962 642 29 433 789 550 812 585 535 876 739 510 571 944 820 882 797 317 413 414 821 228 897 843 413 418 20 310 62 192 169 550 901 786 792 657 947 691 855 727 602 998 995 357 738 782 420 851 89 79 718 894 632 513 572 875 674 176 920 436 256 821 132 72 849 345 580 174 766 488 626 178 363 117...
output:
61540
result:
ok single line: '61540'
Test #33:
score: 0
Accepted
time: 18ms
memory: 4624kb
input:
1000 100000 135 763 958 592 647 755 96 30 826 508 153 244 862 777 644 14 86 227 988 803 577 220 271 864 889 507 498 183 261 889 841 700 982 583 479 228 933 607 318 758 274 741 369 145 648 871 35 124 350 592 995 747 846 380 866 378 281 575 73 797 280 753 819 528 529 328 379 652 468 996 537 937 466 9 ...
output:
10033
result:
ok single line: '10033'
Test #34:
score: 0
Accepted
time: 106ms
memory: 10948kb
input:
1000 500000 462 858 517 675 811 430 341 423 122 682 445 279 825 726 110 455 218 545 586 118 305 597 552 345 807 393 163 696 650 806 596 775 635 995 884 159 262 146 283 682 981 200 956 106 974 216 446 514 360 305 300 843 74 532 782 753 701 567 438 948 452 628 188 736 67 170 619 437 222 571 625 727 16...
output:
4406
result:
ok single line: '4406'
Test #35:
score: 0
Accepted
time: 110ms
memory: 10912kb
input:
10000 500000 2870 6853 872 9320 205 718 8007 5454 783 8990 5319 76 2650 1222 48 3254 7814 795 428 4549 561 9231 4578 75 1785 6185 516 8144 6687 449 5970 7921 622 501 9237 483 2256 9656 685 3500 2465 917 6163 3715 330 7664 8032 123 3151 2685 436 8276 2378 39 6008 1970 502 515 6844 244 8044 5338 946 8...
output:
127943
result:
ok single line: '127943'
Test #36:
score: 0
Accepted
time: 133ms
memory: 11760kb
input:
100000 500000 47844 45008 786 72263 22812 292 11339 51871 913 30811 40408 444 11259 24698 685 40317 26423 306 13806 72501 340 41464 17270 51 34278 97333 603 44882 84071 390 60415 58113 265 29205 92153 29 36213 95950 378 96250 74183 955 55569 36198 119 29081 56383 398 36409 76345 996 62895 47766 168 ...
output:
12044196
result:
ok single line: '12044196'
Test #37:
score: 0
Accepted
time: 22ms
memory: 3616kb
input:
1000 10000 224 608 374 666 376 667 338 310 763 941 335 581 29 148 960 715 103 365 229 965 998 761 784 956 278 173 523 943 668 997 922 959 17 785 873 618 77 715 587 249 424 358 411 822 724 493 60 375 702 629 182 106 905 43 609 830 323 353 290 814 69 512 391 102 982 797 902 381 935 1 124 858 318 239 9...
output:
61720
result:
ok single line: '61720'
Test #38:
score: 0
Accepted
time: 42ms
memory: 4568kb
input:
1000 100000 879 175 809 383 382 795 991 410 883 737 145 82 468 846 91 933 318 620 710 893 41 15 501 197 724 471 114 293 108 9 192 633 606 984 107 214 179 862 512 488 493 970 766 83 832 502 955 852 835 512 298 395 311 512 59 314 736 904 695 1000 214 580 187 565 431 454 567 220 329 402 62 428 712 382 ...
output:
8569
result:
ok single line: '8569'
Test #39:
score: 0
Accepted
time: 120ms
memory: 10948kb
input:
1000 500000 480 625 239 545 57 466 571 149 292 571 849 18 721 961 130 328 284 100 198 563 318 387 597 144 170 582 102 500 793 466 836 453 294 121 539 94 323 767 888 512 379 406 935 244 45 459 74 617 711 494 257 860 113 14 292 115 646 787 283 209 143 34 991 686 63 365 6 132 975 96 754 739 572 789 963...
output:
4890
result:
ok single line: '4890'
Test #40:
score: 0
Accepted
time: 116ms
memory: 10876kb
input:
10000 500000 1184 3108 786 7191 748 754 5726 987 56 1471 8722 327 6546 1456 69 7616 9880 350 9632 289 574 3021 4111 386 2148 374 943 8652 7726 109 6210 302 282 6331 6404 419 6317 5277 482 4818 7055 227 8438 661 890 1610 5069 522 3207 3171 984 5293 3712 817 7326 9628 639 31 5689 209 4030 9448 749 556...
output:
127883
result:
ok single line: '127883'
Test #41:
score: 0
Accepted
time: 128ms
memory: 11744kb
input:
100000 500000 40336 65199 890 30060 65236 106 67286 77915 209 56187 10043 212 14232 58876 554 6021 2171 189 59945 63760 369 97468 19040 971 33350 96119 500 71833 39656 659 47871 71840 755 65481 19310 657 85702 94867 794 27923 55476 292 26008 98817 972 51309 31665 783 47594 46441 898 83392 84411 322 ...
output:
11999983
result:
ok single line: '11999983'
Test #42:
score: 0
Accepted
time: 143ms
memory: 11740kb
input:
100000 500000 8226 60312 567 18835 75398 860 85546 70810 851 83013 63436 104 30616 95787 110 73441 43083 749 69760 26331 444 70749 19699 275 42696 86783 215 62664 45551 494 50406 50543 637 88232 93311 309 16509 34493 892 25200 56313 99 58516 78455 116 12933 20322 797 70264 50271 900 74674 87496 164 ...
output:
12078007
result:
ok single line: '12078007'
Test #43:
score: 0
Accepted
time: 144ms
memory: 11744kb
input:
100000 500000 14015 66511 846 14844 17439 481 49642 37691 134 52427 2485 104 50940 15059 811 97244 67072 235 98506 99922 803 54346 37125 140 72913 54521 676 42748 62460 767 3466 1980 464 28494 5982 143 47696 12651 26 81597 86864 217 27247 3971 32 71991 92495 112 84336 3221 578 29730 72030 259 53314 ...
output:
12030841
result:
ok single line: '12030841'
Test #44:
score: 0
Accepted
time: 139ms
memory: 11712kb
input:
100000 500000 68899 84939 145 23626 741 43 97101 25805 878 58777 31242 879 77033 63358 243 59209 29205 30 27531 46745 806 80353 96615 338 4219 88931 23 65817 89878 381 12185 13593 31 66433 91614 8 99281 54713 691 26192 31788 40 2882 11791 745 18415 27270 607 89417 70018 714 41319 10623 177 77203 176...
output:
12038110
result:
ok single line: '12038110'
Test #45:
score: 0
Accepted
time: 157ms
memory: 11748kb
input:
100000 500000 28077 87098 491 63018 86420 937 47493 28257 288 19626 83124 128 12799 82443 926 28446 79780 802 3259 25972 448 75797 47587 321 37349 79803 354 94856 29850 457 52571 62605 898 79903 67698 588 17852 7920 145 71938 64892 685 29588 94833 801 83299 55805 368 71013 70960 224 3401 9048 530 14...
output:
12021023
result:
ok single line: '12021023'
Test #46:
score: 0
Accepted
time: 139ms
memory: 11668kb
input:
100000 500000 88624 4720 414 32282 98044 485 50028 88748 739 15660 1037 491 99705 52261 201 21803 68806 357 86954 88402 886 22783 24877 244 30177 1797 293 99312 16195 779 99712 54009 893 13941 1264 511 18418 78493 882 96955 54859 414 6746 68670 852 29075 38030 930 91708 48153 463 81599 43001 912 724...
output:
12055013
result:
ok single line: '12055013'
Test #47:
score: 0
Accepted
time: 146ms
memory: 11772kb
input:
100000 500000 80534 86487 135 69276 9099 875 37098 85054 573 59836 93529 481 69178 56997 946 22419 43987 611 40849 94738 156 20529 75845 188 543 84045 593 44681 61066 952 56740 89731 948 12250 39345 813 67676 70301 16 2849 97330 309 91435 86208 948 8286 71890 263 50475 97286 576 62436 19731 38 11539...
output:
12028022
result:
ok single line: '12028022'
Test #48:
score: 0
Accepted
time: 103ms
memory: 11676kb
input:
100000 500000 1 4 2 1 9 3 1 7 4 1 3 5 1 4 6 1 9 7 1 9 8 1 5 9 1 6 10 1 10 11 1 535 12 1 184 13 1 640 14 1 578 15 1 635 16 1 625 17 1 445 18 1 348 19 1 446 20 1 102 21 1 842 22 1 813 23 1 633 24 1 693 25 1 248 26 1 411 27 1 489 28 1 685 29 1 895 30 1 762 31 1 84 32 1 470 33 1 655 34 1 183 35 1 739 36...
output:
33023386
result:
ok single line: '33023386'
Test #49:
score: 0
Accepted
time: 118ms
memory: 11792kb
input:
100000 500000 1 6 2 1 8 3 1 6 4 1 7 5 1 3 6 1 3 7 1 10 8 1 1 9 1 7 10 1 1 11 1 370 12 1 447 13 1 919 14 1 189 15 1 399 16 1 854 17 1 330 18 1 780 19 1 211 20 1 320 21 1 96 22 1 603 23 1 779 24 1 15 25 1 366 26 1 381 27 1 409 28 1 671 29 1 685 30 1 729 31 1 741 32 1 139 33 1 252 34 1 79 35 1 382 36 1...
output:
32918956
result:
ok single line: '32918956'
Test #50:
score: 0
Accepted
time: 107ms
memory: 11740kb
input:
100000 500000 1 10 2 1 5 3 1 7 4 1 5 5 1 7 6 1 5 7 1 5 8 1 5 9 1 4 10 1 4 11 1 690 12 1 857 13 1 29 14 1 189 15 1 659 16 1 370 17 1 490 18 1 909 19 1 108 20 1 94 21 1 221 22 1 87 23 1 166 24 1 585 25 1 765 26 1 520 27 1 237 28 1 77 29 1 410 30 1 692 31 1 919 32 1 408 33 1 340 34 1 945 35 1 726 36 1 ...
output:
33117703
result:
ok single line: '33117703'
Test #51:
score: 0
Accepted
time: 107ms
memory: 11740kb
input:
100000 500000 1 4 2 1 3 3 1 6 4 1 1 5 1 5 6 1 1 7 1 5 8 1 4 9 1 8 10 1 2 11 1 422 12 1 863 13 1 929 14 1 859 15 1 40 16 1 534 17 1 76 18 1 424 19 1 610 20 1 615 21 1 799 22 1 743 23 1 888 24 1 114 25 1 150 26 1 180 27 1 917 28 1 909 29 1 740 30 1 29 31 1 720 32 1 731 33 1 478 34 1 564 35 1 185 36 1 ...
output:
33156473
result:
ok single line: '33156473'
Test #52:
score: 0
Accepted
time: 109ms
memory: 11756kb
input:
100000 500000 1 9 2 1 6 3 1 5 4 1 2 5 1 7 6 1 7 7 1 8 8 1 3 9 1 8 10 1 5 11 1 878 12 1 224 13 1 267 14 1 630 15 1 549 16 1 625 17 1 17 18 1 396 19 1 499 20 1 995 21 1 568 22 1 669 23 1 195 24 1 627 25 1 146 26 1 866 27 1 473 28 1 561 29 1 269 30 1 36 31 1 99 32 1 486 33 1 146 34 1 336 35 1 25 36 1 2...
output:
32976452
result:
ok single line: '32976452'
Test #53:
score: 0
Accepted
time: 107ms
memory: 11680kb
input:
100000 500000 1 2 2 1 7 3 1 7 4 1 10 5 1 1 6 1 1 7 1 10 8 1 8 9 1 6 10 1 7 11 1 522 12 1 388 13 1 771 14 1 782 15 1 810 16 1 771 17 1 695 18 1 513 19 1 945 20 1 194 21 1 344 22 1 41 23 1 182 24 1 66 25 1 920 26 1 697 27 1 314 28 1 577 29 1 204 30 1 319 31 1 157 32 1 361 33 1 905 34 1 814 35 1 893 36...
output:
33109755
result:
ok single line: '33109755'
Test #54:
score: 0
Accepted
time: 113ms
memory: 11660kb
input:
100000 500000 1 3 2 1 10 3 1 5 4 1 3 5 1 8 6 1 6 7 1 8 8 1 9 9 1 7 10 1 8 11 1 899 12 1 652 13 1 786 14 1 747 15 1 63 16 1 716 17 1 344 18 1 847 19 1 500 20 1 788 21 1 397 22 1 489 23 1 330 24 1 993 25 1 329 26 1 641 27 1 462 28 1 43 29 1 602 30 1 408 31 1 615 32 1 498 33 1 697 34 1 165 35 1 54 36 1...
output:
33230960
result:
ok single line: '33230960'
Test #55:
score: 0
Accepted
time: 104ms
memory: 11668kb
input:
100000 500000 1 6 2 1 1 3 1 3 4 1 6 5 1 5 6 1 4 7 1 4 8 1 1 9 1 4 10 1 5 11 1 471 12 1 927 13 1 806 14 1 37 15 1 164 16 1 125 17 1 43 18 1 86 19 1 98 20 1 274 21 1 777 22 1 191 23 1 269 24 1 583 25 1 843 26 1 818 27 1 864 28 1 273 29 1 205 30 1 678 31 1 274 32 1 355 33 1 84 34 1 637 35 1 923 36 1 43...
output:
33127294
result:
ok single line: '33127294'
Test #56:
score: 0
Accepted
time: 111ms
memory: 11740kb
input:
100000 500000 1 6 2 1 2 3 1 3 4 1 4 5 1 10 6 1 8 7 1 1 8 1 10 9 1 3 10 1 3 11 1 784 12 1 741 13 1 946 14 1 853 15 1 890 16 1 973 17 1 25 18 1 535 19 1 61 20 1 227 21 1 219 22 1 778 23 1 945 24 1 629 25 1 16 26 1 964 27 1 773 28 1 890 29 1 71 30 1 890 31 1 157 32 1 771 33 1 778 34 1 166 35 1 764 36 1...
output:
33124734
result:
ok single line: '33124734'
Test #57:
score: 0
Accepted
time: 96ms
memory: 11680kb
input:
100000 500000 1 7 2 1 5 3 1 10 4 1 3 5 1 3 6 1 10 7 1 10 8 1 5 9 1 4 10 1 10 11 1 534 12 1 310 13 1 699 14 1 242 15 1 96 16 1 388 17 1 905 18 1 881 19 1 20 20 1 375 21 1 75 22 1 426 23 1 221 24 1 73 25 1 855 26 1 200 27 1 366 28 1 134 29 1 407 30 1 418 31 1 64 32 1 738 33 1 105 34 1 537 35 1 457 36 ...
output:
33130426
result:
ok single line: '33130426'
Test #58:
score: 0
Accepted
time: 107ms
memory: 11688kb
input:
100000 500000 1 2 2 1 10 3 1 7 4 1 8 5 1 5 6 1 4 7 1 9 8 1 3 9 1 9 10 1 5 11 1 567 12 1 394 13 1 410 14 1 332 15 1 790 16 1 418 17 1 146 18 1 964 19 1 63 20 1 63 21 1 314 22 1 1000 23 1 114 24 1 477 25 1 680 26 1 261 27 1 668 28 1 934 29 1 38 30 1 560 31 1 484 32 1 96 33 1 243 34 1 149 35 1 34 36 1 ...
output:
33045056
result:
ok single line: '33045056'
Test #59:
score: 0
Accepted
time: 125ms
memory: 11688kb
input:
100000 500000 1 4 2 1 4 3 1 6 4 1 1 5 1 3 6 1 3 7 1 2 8 1 10 9 1 5 10 1 1 11 1 45 12 1 674 13 1 808 14 1 940 15 1 597 16 1 656 17 1 367 18 1 473 19 1 358 20 1 250 21 1 518 22 1 211 23 1 182 24 1 480 25 1 196 26 1 500 27 1 854 28 1 297 29 1 170 30 1 923 31 1 752 32 1 838 33 1 519 34 1 554 35 1 376 36...
output:
33005475
result:
ok single line: '33005475'
Test #60:
score: 0
Accepted
time: 78ms
memory: 11680kb
input:
100000 500000 1 9 2 1 5 3 1 9 4 1 2 5 1 7 6 1 10 7 1 6 8 1 10 9 1 1 10 1 8 11 1 815 12 1 213 13 1 772 14 1 497 15 1 987 16 1 381 17 1 797 18 1 943 19 1 458 20 1 280 21 1 657 22 1 619 23 1 443 24 1 947 25 1 490 26 1 419 27 1 717 28 1 847 29 1 397 30 1 267 31 1 820 32 1 803 33 1 645 34 1 384 35 1 282 ...
output:
33193923
result:
ok single line: '33193923'
Test #61:
score: 0
Accepted
time: 109ms
memory: 11752kb
input:
100000 500000 1 7 2 1 5 3 1 3 4 1 6 5 1 4 6 1 10 7 1 7 8 1 6 9 1 9 10 1 2 11 1 37 12 1 155 13 1 799 14 1 515 15 1 122 16 1 953 17 1 518 18 1 598 19 1 530 20 1 881 21 1 850 22 1 472 23 1 992 24 1 749 25 1 34 26 1 372 27 1 895 28 1 360 29 1 158 30 1 737 31 1 560 32 1 215 33 1 181 34 1 192 35 1 632 36 ...
output:
33224164
result:
ok single line: '33224164'
Test #62:
score: 0
Accepted
time: 92ms
memory: 11692kb
input:
100000 500000 1 4 2 1 1 3 1 7 4 1 6 5 1 4 6 1 1 7 1 3 8 1 9 9 1 6 10 1 1 11 1 792 12 1 565 13 1 463 14 1 194 15 1 705 16 1 652 17 1 529 18 1 742 19 1 894 20 1 629 21 1 298 22 1 867 23 1 310 24 1 981 25 1 148 26 1 862 27 1 950 28 1 461 29 1 278 30 1 92 31 1 157 32 1 682 33 1 72 34 1 145 35 1 459 36 1...
output:
33088891
result:
ok single line: '33088891'
Test #63:
score: 0
Accepted
time: 100ms
memory: 11796kb
input:
100000 500000 1 6 2 1 2 3 1 9 4 1 9 5 1 9 6 1 9 7 1 8 8 1 9 9 1 1 10 1 2 11 1 774 12 1 353 13 1 30 14 1 47 15 1 897 16 1 607 17 1 678 18 1 64 19 1 718 20 1 21 21 1 352 22 1 978 23 1 259 24 1 286 25 1 73 26 1 473 27 1 521 28 1 692 29 1 731 30 1 476 31 1 713 32 1 429 33 1 877 34 1 259 35 1 641 36 1 95...
output:
33178382
result:
ok single line: '33178382'
Test #64:
score: 0
Accepted
time: 106ms
memory: 11740kb
input:
100000 500000 1 3 2 1 8 3 1 7 4 1 9 5 1 4 6 1 8 7 1 10 8 1 2 9 1 4 10 1 10 11 1 65 12 1 585 13 1 843 14 1 504 15 1 937 16 1 561 17 1 429 18 1 634 19 1 787 20 1 864 21 1 980 22 1 672 23 1 553 24 1 757 25 1 127 26 1 710 27 1 400 28 1 679 29 1 575 30 1 649 31 1 950 32 1 63 33 1 76 34 1 702 35 1 212 36 ...
output:
33016784
result:
ok single line: '33016784'
Test #65:
score: 0
Accepted
time: 92ms
memory: 11688kb
input:
100000 500000 1 9 2 1 8 3 1 10 4 1 2 5 1 10 6 1 9 7 1 1 8 1 7 9 1 5 10 1 3 11 1 593 12 1 405 13 1 399 14 1 615 15 1 449 16 1 178 17 1 399 18 1 374 19 1 804 20 1 654 21 1 534 22 1 658 23 1 823 24 1 804 25 1 17 26 1 924 27 1 764 28 1 430 29 1 785 30 1 988 31 1 204 32 1 40 33 1 230 34 1 27 35 1 52 36 1...
output:
33085328
result:
ok single line: '33085328'
Test #66:
score: 0
Accepted
time: 104ms
memory: 11684kb
input:
100000 500000 1 9 2 1 6 3 1 5 4 1 2 5 1 3 6 1 7 7 1 10 8 1 9 9 1 2 10 1 2 11 1 668 12 1 875 13 1 808 14 1 276 15 1 905 16 1 666 17 1 819 18 1 892 19 1 321 20 1 968 21 1 982 22 1 33 23 1 550 24 1 217 25 1 596 26 1 387 27 1 636 28 1 335 29 1 186 30 1 252 31 1 961 32 1 969 33 1 514 34 1 864 35 1 959 36...
output:
33249844
result:
ok single line: '33249844'
Test #67:
score: 0
Accepted
time: 106ms
memory: 11760kb
input:
100000 500000 1 8 2 1 10 3 1 10 4 1 8 5 1 7 6 1 4 7 1 3 8 1 4 9 1 8 10 1 8 11 1 756 12 1 909 13 1 800 14 1 301 15 1 697 16 1 458 17 1 769 18 1 338 19 1 506 20 1 533 21 1 909 22 1 742 23 1 828 24 1 711 25 1 569 26 1 915 27 1 424 28 1 940 29 1 217 30 1 585 31 1 23 32 1 840 33 1 23 34 1 999 35 1 47 36 ...
output:
32976443
result:
ok single line: '32976443'
Test #68:
score: 0
Accepted
time: 93ms
memory: 11688kb
input:
100000 500000 1 6 2 1 2 3 1 5 4 1 3 5 1 8 6 1 1 7 1 7 8 1 10 9 1 6 10 1 1 11 1 400 12 1 570 13 1 486 14 1 356 15 1 834 16 1 761 17 1 17 18 1 786 19 1 912 20 1 693 21 1 282 22 1 648 23 1 139 24 1 307 25 1 25 26 1 781 27 1 920 28 1 100 29 1 469 30 1 747 31 1 877 32 1 495 33 1 704 34 1 368 35 1 115 36 ...
output:
32971189
result:
ok single line: '32971189'
Test #69:
score: 0
Accepted
time: 89ms
memory: 11680kb
input:
100000 500000 1 9 2 1 2 3 1 7 4 1 1 5 1 6 6 1 5 7 1 5 8 1 4 9 1 10 10 1 7 11 1 296 12 1 770 13 1 362 14 1 720 15 1 171 16 1 7 17 1 876 18 1 691 19 1 706 20 1 408 21 1 221 22 1 695 23 1 578 24 1 951 25 1 435 26 1 335 27 1 301 28 1 823 29 1 153 30 1 883 31 1 627 32 1 389 33 1 346 34 1 985 35 1 43 36 1...
output:
33068438
result:
ok single line: '33068438'
Test #70:
score: 0
Accepted
time: 89ms
memory: 11660kb
input:
100000 500000 1 10 2 1 10 3 1 4 4 1 8 5 1 7 6 1 6 7 1 5 8 1 2 9 1 9 10 1 6 11 1 293 12 1 805 13 1 541 14 1 825 15 1 716 16 1 172 17 1 345 18 1 357 19 1 208 20 1 22 21 1 927 22 1 980 23 1 162 24 1 202 25 1 352 26 1 316 27 1 822 28 1 38 29 1 90 30 1 983 31 1 226 32 1 667 33 1 431 34 1 252 35 1 96 36 1...
output:
32963097
result:
ok single line: '32963097'
Test #71:
score: 0
Accepted
time: 108ms
memory: 11752kb
input:
100000 500000 1 6 2 1 7 3 1 5 4 1 1 5 1 6 6 1 8 7 1 3 8 1 2 9 1 10 10 1 1 11 1 549 12 1 588 13 1 982 14 1 952 15 1 326 16 1 153 17 1 272 18 1 241 19 1 587 20 1 32 21 1 751 22 1 982 23 1 217 24 1 468 25 1 782 26 1 73 27 1 427 28 1 984 29 1 722 30 1 961 31 1 776 32 1 784 33 1 286 34 1 488 35 1 688 36 ...
output:
33058357
result:
ok single line: '33058357'
Test #72:
score: 0
Accepted
time: 107ms
memory: 11760kb
input:
100000 500000 1 3 2 1 7 3 1 9 4 1 5 5 1 5 6 1 1 7 1 4 8 1 2 9 1 3 10 1 3 11 1 146 12 1 414 13 1 565 14 1 763 15 1 775 16 1 693 17 1 889 18 1 646 19 1 161 20 1 477 21 1 661 22 1 261 23 1 993 24 1 309 25 1 47 26 1 111 27 1 372 28 1 821 29 1 407 30 1 41 31 1 464 32 1 579 33 1 319 34 1 558 35 1 85 36 1 ...
output:
32923066
result:
ok single line: '32923066'
Test #73:
score: 0
Accepted
time: 108ms
memory: 11676kb
input:
100000 500000 1 3 2 1 2 3 1 1 4 1 4 5 1 8 6 1 4 7 1 5 8 1 6 9 1 10 10 1 4 11 1 12 12 1 731 13 1 786 14 1 76 15 1 153 16 1 688 17 1 813 18 1 260 19 1 332 20 1 621 21 1 241 22 1 297 23 1 585 24 1 670 25 1 82 26 1 551 27 1 602 28 1 789 29 1 588 30 1 901 31 1 159 32 1 279 33 1 395 34 1 548 35 1 935 36 1...
output:
33101150
result:
ok single line: '33101150'
Test #74:
score: 0
Accepted
time: 116ms
memory: 11688kb
input:
100000 500000 1 5 2 1 1 3 1 2 4 1 5 5 1 2 6 1 6 7 1 4 8 1 2 9 1 7 10 1 7 11 1 993 12 1 300 13 1 990 14 1 787 15 1 236 16 1 882 17 1 739 18 1 155 19 1 651 20 1 41 21 1 227 22 1 187 23 1 242 24 1 110 25 1 279 26 1 360 27 1 371 28 1 280 29 1 86 30 1 767 31 1 582 32 1 257 33 1 920 34 1 556 35 1 500 36 1...
output:
32983745
result:
ok single line: '32983745'
Test #75:
score: 0
Accepted
time: 117ms
memory: 11712kb
input:
100000 500000 1 3 2 1 3 3 1 9 4 1 10 5 1 8 6 1 1 7 1 1 8 1 9 9 1 5 10 1 3 11 1 19 12 1 568 13 1 672 14 1 174 15 1 878 16 1 172 17 1 283 18 1 19 19 1 823 20 1 464 21 1 972 22 1 641 23 1 58 24 1 269 25 1 807 26 1 659 27 1 857 28 1 71 29 1 111 30 1 550 31 1 302 32 1 971 33 1 992 34 1 669 35 1 430 36 1 ...
output:
32890965
result:
ok single line: '32890965'
Test #76:
score: 0
Accepted
time: 107ms
memory: 11652kb
input:
100000 500000 1 2 2 1 4 3 1 3 4 1 9 5 1 2 6 1 10 7 1 8 8 1 10 9 1 3 10 1 4 11 1 401 12 1 830 13 1 176 14 1 207 15 1 89 16 1 301 17 1 678 18 1 157 19 1 862 20 1 466 21 1 675 22 1 990 23 1 747 24 1 243 25 1 753 26 1 182 27 1 852 28 1 321 29 1 254 30 1 11 31 1 38 32 1 28 33 1 554 34 1 288 35 1 988 36 1...
output:
33198709
result:
ok single line: '33198709'
Test #77:
score: 0
Accepted
time: 157ms
memory: 11748kb
input:
100000 500000 1554 85186 493 38450 10186 941 99512 87159 889 3468 14638 248 30258 39563 778 13033 2972 802 5814 65830 521 90388 8638 59 55457 68808 531 35426 63181 267 13202 14793 276 50804 66026 937 16809 30159 202 77488 18882 267 7616 68560 235 85020 88707 526 22953 57033 145 54971 58040 615 18186...
output:
12154688
result:
ok single line: '12154688'
Test #78:
score: 0
Accepted
time: 140ms
memory: 11732kb
input:
100000 500000 72558 49732 947 19894 99358 621 26506 2904 395 70085 53834 180 20567 23142 4 41150 93896 560 49778 53551 872 81340 50142 988 73403 78426 585 57878 32668 444 89717 4208 496 98713 98363 140 37569 69371 471 57158 61308 345 20502 12703 876 78574 87967 835 14213 68824 999 42764 30497 986 51...
output:
12084727
result:
ok single line: '12084727'
Test #79:
score: 0
Accepted
time: 136ms
memory: 11688kb
input:
100000 500000 41762 53272 520 75842 20785 741 30542 83129 863 46037 71041 789 67700 37352 985 60329 56109 965 63439 34526 601 56510 61133 998 59278 55255 65 43465 87860 163 2351 47283 72 35831 57772 404 80571 39405 179 76998 79313 59 7876 99835 539 66657 17040 965 12669 3399 343 79420 91648 420 3068...
output:
12096532
result:
ok single line: '12096532'