QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291179 | #1211. Card Game Is Great Fun | MoRanSky | 100 ✓ | 298ms | 506948kb | C++23 | 1.7kb | 2023-12-26 05:14:28 | 2023-12-26 05:14:29 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstring>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long LL;
using namespace std;
template <typename T> void inline chkMax(T &x, T y) { if (y > x) x = y; }
template <typename T> void inline chkMin(T &x, T y) { if (y < x) x = y; }
template <typename T> void inline read(T &x) {
int f = 1; x = 0; char s = getchar();
while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
x *= f;
}
template <typename T> void print(T x) {
if (x < 0) { putchar('-'); print(x); return ; }
if (x >= 10) print(x / 10);
putchar((x % 10) + '0');
}
const int N = 505, INF = 0xcfcfcfcf;
int n, C[N], A[N], V[N], ans = INF;
int f[N][N][N];
int main() {
memset(f, 0xcf, sizeof f);
read(n);
for (int i = 1; i <= n; i++) {
read(C[i]), read(A[i]), read(V[i]);
}
f[2][3][1] = V[1];
f[1][2][3] = V[3];
for (int i = 0; i <= n + 2; i++) {
for (int j = 0; j <= n + 2; j++) {
if (i && i == j) continue;
for (int k = 0; k <= n + 2; k++) {
if (f[i][j][k] == INF) continue;
chkMax(ans, f[i][j][k]);
int v = f[i][j][k];
if (k > j) {
if (C[i] == C[k] || A[i] == A[k]) chkMax(f[j][k + 1][i], v + V[i]);
if (k < n && (C[k + 1] == C[k] || A[k + 1] == A[k]))
chkMax(f[i][j][k + 1], v + V[k + 1]);
}
// flag
if (k < i) {
if (C[k] == C[i] || A[k] == A[i])
chkMax(f[j][j + 1][i], v + V[i]);
if (j < n && (C[j + 1] == C[k] || A[j + 1] == A[k]))
chkMax(f[i][j][j + 1], v + V[j + 1]);
}
}
}
}
printf("%d\n", ans);
}
詳細信息
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 23ms
memory: 506700kb
input:
1 100 200 300
output:
300
result:
ok single line: '300'
Test #2:
score: 0
Accepted
time: 27ms
memory: 506704kb
input:
2 10 30 50 20 30 60
output:
110
result:
ok single line: '110'
Test #3:
score: 0
Accepted
time: 28ms
memory: 506708kb
input:
3 1 1 872619 1 1 269575 2 1 866585
output:
2008779
result:
ok single line: '2008779'
Test #4:
score: 0
Accepted
time: 24ms
memory: 506588kb
input:
4 2 3 310822 2 3 753269 2 2 488983 2 2 553449
output:
2106523
result:
ok single line: '2106523'
Test #5:
score: 0
Accepted
time: 15ms
memory: 506708kb
input:
20 1 1 332713 2 2 906654 1 1 757460 2 1 790347 1 2 478732 1 1 350044 2 1 676301 1 2 566708 1 2 167953 1 2 467699 2 2 322359 1 1 220330 1 1 670697 1 2 928847 1 2 741161 1 1 179652 1 1 92027 2 1 373947 1 1 338363 1 2 68434
output:
9430428
result:
ok single line: '9430428'
Test #6:
score: 0
Accepted
time: 7ms
memory: 506700kb
input:
20 1 3 945037 2 3 232413 1 2 148053 2 1 725817 3 1 270828 1 2 340805 3 2 220403 1 1 308154 2 2 676216 2 1 150340 2 1 646975 1 3 252616 1 2 323633 2 3 414440 1 3 363244 2 2 374275 2 2 890202 3 3 872367 1 2 256124 3 3 558036
output:
7539575
result:
ok single line: '7539575'
Test #7:
score: 0
Accepted
time: 24ms
memory: 506704kb
input:
20 3 1 794171 6 6 282031 15 5 397435 2 5 928137 1 13 297948 6 12 949273 13 10 376859 16 6 627784 20 13 137297 18 6 422032 7 18 524418 3 7 255566 2 13 729965 10 10 441949 7 3 263274 12 10 944708 19 18 407575 3 2 107773 16 6 222743 8 5 875528
output:
1325572
result:
ok single line: '1325572'
Test #8:
score: 0
Accepted
time: 23ms
memory: 506836kb
input:
20 2 4 947445 2 4 173957 4 4 761167 2 2 762181 2 4 953814 5 4 951410 5 3 137882 1 4 403446 2 4 269703 1 2 733669 1 1 358660 5 1 247314 2 2 208922 5 3 136709 5 5 170151 1 4 910545 4 2 946606 4 1 303168 1 4 938711 1 4 586832
output:
5608319
result:
ok single line: '5608319'
Test #9:
score: 0
Accepted
time: 31ms
memory: 506548kb
input:
20 17 1 528215 9 1 27889 4 1 484106 3 1 361086 13 1 684741 1 1 319531 7 2 114013 17 1 333927 11 1 273268 20 1 117943 6 1 682093 16 3 539795 12 2 22123 13 1 571167 20 3 298612 13 3 46437 7 2 951589 16 3 132618 9 1 625780 20 2 228827
output:
3812799
result:
ok single line: '3812799'
Test #10:
score: 0
Accepted
time: 15ms
memory: 506868kb
input:
20 19 14 428320 19 12 659711 19 8 624591 19 14 875531 13 14 986046 1 17 566194 15 5 817311 17 2 834746 2 7 365839 7 15 206528 6 11 253911 11 13 222840 16 11 418027 16 19 873135 11 19 96842 18 9 3156 5 14 617520 8 20 380590 2 19 430746 16 19 252068
output:
3574199
result:
ok single line: '3574199'
Test #11:
score: 0
Accepted
time: 19ms
memory: 506712kb
input:
20 282 298 571660 401 351 110486 218 255 635323 366 416 124957 451 371 534807 203 230 668916 60 150 492998 294 138 968746 187 493 151309 383 38 281350 469 236 107757 354 350 591687 462 90 573666 176 457 127656 428 265 53034 152 459 500298 92 22 426534 406 149 98142 334 141 790473 410 137 47185
output:
635323
result:
ok single line: '635323'
Test #12:
score: 0
Accepted
time: 19ms
memory: 506600kb
input:
20 2 1 898433 1 3 852344 1 3 257819 1 3 41619 1 3 35106 1 1 690774 1 1 825110 1 3 831171 2 2 209953 1 2 844760 1 2 540353 1 1 862197 1 2 544601 2 3 356002 1 3 690361 2 3 461923 2 3 853494 2 3 228225 2 3 911105 2 3 844288
output:
11779638
result:
ok single line: '11779638'
Test #13:
score: 0
Accepted
time: 15ms
memory: 506712kb
input:
20 5 5 97036 1 5 155754 2 5 855309 2 5 587786 2 5 273328 2 5 874701 2 4 809381 2 4 199101 4 2 545 4 2 370136 4 2 510770 4 2 453070 4 2 733751 3 2 125981 4 2 480924 4 5 134707 4 5 589338 4 4 742281 1 4 807983 4 3 825840
output:
3852396
result:
ok single line: '3852396'
Test #14:
score: 0
Accepted
time: 27ms
memory: 506652kb
input:
20 2 3 691851 1 2 505370 2 3 86457 2 2 476562 3 2 8502 2 2 496217 2 2 706929 2 2 352591 2 2 343616 2 2 897565 2 2 870989 2 2 646617 2 2 273189 2 3 740702 2 3 548948 2 3 993887 3 3 637135 3 3 178613 3 3 51483 3 3 787743
output:
10294966
result:
ok single line: '10294966'
Test #15:
score: 0
Accepted
time: 15ms
memory: 506700kb
input:
20 3 2 698287 3 1 721886 3 2 733007 1 1 801893 3 1 337639 1 3 665798 1 3 767522 3 5 427751 3 3 247676 3 3 508169 3 1 738122 3 1 410957 3 1 826202 3 1 560643 3 1 907029 3 1 83568 3 3 955757 3 1 372003 3 1 586244 3 3 819079
output:
12169232
result:
ok single line: '12169232'
Test #16:
score: 0
Accepted
time: 12ms
memory: 506948kb
input:
20 9 9 703288 3 9 421429 3 9 743015 3 9 293805 3 9 821306 3 10 809501 3 9 518183 3 9 426246 3 15 65658 3 15 786552 9 15 721504 9 15 116775 2 15 495835 9 15 500336 2 10 499534 2 10 213955 1 9 785939 1 3 112687 1 9 739348 1 9 605219
output:
9666626
result:
ok single line: '9666626'
Test #17:
score: 0
Accepted
time: 35ms
memory: 506640kb
input:
20 15 6 846932 11 6 433153 2 6 578783 11 6 636905 19 6 327646 19 6 889349 10 6 120030 19 6 242562 13 6 796789 14 6 300472 18 6 939742 14 6 783617 18 6 546601 14 6 321778 18 6 132245 8 6 565270 8 6 47660 8 6 11580 8 6 883017 8 6 156270
output:
9560401
result:
ok single line: '9560401'
Test #18:
score: 0
Accepted
time: 20ms
memory: 506712kb
input:
20 9 11 890881 9 8 151072 6 11 376366 12 11 947008 14 20 698918 9 16 524279 16 20 559141 14 8 661711 16 10 559978 17 20 834599 16 16 349428 16 18 310674 16 12 196360 16 12 782332 16 10 412361 15 10 487587 16 10 939850 18 8 895438 16 15 361866 9 4 642497
output:
10044411
result:
ok single line: '10044411'
Test #19:
score: 0
Accepted
time: 24ms
memory: 506704kb
input:
20 6 13 226042 1 11 91039 1 11 278856 1 13 373939 13 11 434870 1 7 289713 8 11 845692 2 11 894049 2 7 921898 8 20 342602 8 1 374092 2 1 569241 2 1 672957 8 1 553289 8 7 969385 8 1 282263 8 12 693928 18 13 569635 16 1 862195 2 12 457439
output:
9676050
result:
ok single line: '9676050'
Test #20:
score: 0
Accepted
time: 15ms
memory: 506648kb
input:
20 14 4 948111 17 4 984075 14 1 276291 6 4 253065 1 4 221889 1 4 244935 6 4 981404 14 17 680697 17 6 27952 6 1 957839 14 1 632106 14 17 747838 14 16 459141 14 3 675382 2 18 480352 5 18 36703 2 16 763597 5 1 961520 19 3 684268 6 14 839288
output:
8062773
result:
ok single line: '8062773'
Subtask #2:
score: 15
Accepted
Test #21:
score: 15
Accepted
time: 32ms
memory: 506704kb
input:
1 300 200 100
output:
100
result:
ok single line: '100'
Test #22:
score: 0
Accepted
time: 28ms
memory: 506640kb
input:
2 60 40 20 60 30 10
output:
30
result:
ok single line: '30'
Test #23:
score: 0
Accepted
time: 41ms
memory: 506700kb
input:
3 2 1 451149 1 2 258077 1 2 202571
output:
451149
result:
ok single line: '451149'
Test #24:
score: 0
Accepted
time: 3ms
memory: 506712kb
input:
30 1 1 742825 1 2 60596 2 1 290377 1 2 844183 2 1 646840 1 2 515437 2 1 271239 1 1 414370 2 2 353451 1 2 367087 2 1 765101 2 2 15346 1 1 322499 1 1 618164 2 1 330602 1 1 185665 2 1 435179 1 1 451180 2 2 744481 1 1 184382 2 1 900227 1 1 295881 2 1 673865 1 1 873913 1 2 99829 2 1 698646 2 1 861801 1 1...
output:
13873492
result:
ok single line: '13873492'
Test #25:
score: 0
Accepted
time: 40ms
memory: 506704kb
input:
50 2 3 88092 1 2 156631 3 3 689085 2 3 212914 1 1 890296 3 2 674863 3 3 322235 2 1 112715 3 2 370385 1 1 34778 1 2 195353 2 1 820 1 3 157742 2 3 914201 2 1 697525 3 2 44955 2 3 999753 3 1 155957 3 3 456317 2 1 645658 1 1 263449 3 2 36393 2 2 303473 3 2 853467 3 1 506999 2 1 330258 2 3 747371 1 3 143...
output:
990091
result:
ok single line: '990091'
Test #26:
score: 0
Accepted
time: 24ms
memory: 506708kb
input:
50 3 2 52866 3 3 665706 4 3 294643 1 1 993136 4 2 230560 1 2 424435 2 1 436323 3 2 721936 1 3 339992 3 2 594453 4 1 827895 4 3 871596 4 3 726738 2 1 828444 2 1 500001 3 2 232921 2 1 357279 3 1 305587 4 3 839771 1 1 201101 3 2 715488 1 3 889351 2 2 165417 2 2 934272 4 1 958527 3 3 932603 1 1 641324 3...
output:
1013215
result:
ok single line: '1013215'
Test #27:
score: 0
Accepted
time: 32ms
memory: 506656kb
input:
50 34 39 218620 49 18 566525 23 38 437832 4 40 35876 40 16 538782 50 5 275307 31 49 202734 44 16 219179 21 39 191630 13 3 434331 6 16 154298 22 1 487391 42 11 631268 3 11 54435 43 46 877322 28 35 724709 13 49 988607 10 12 755073 41 50 412469 4 22 625627 27 2 689225 43 26 490098 25 42 355290 3 16 994...
output:
437832
result:
ok single line: '437832'
Test #28:
score: 0
Accepted
time: 27ms
memory: 506840kb
input:
50 1 3 725670 2 2 951361 1 3 571031 1 2 411212 2 3 882414 1 2 857270 1 2 910266 1 1 954949 1 2 525793 2 2 122458 3 1 393438 3 1 587211 3 3 734443 3 2 452480 3 3 608504 3 2 68630 1 2 448758 3 2 154946 3 1 251769 2 1 502569 3 2 324096 3 1 70046 3 1 134834 3 2 129937 3 1 970373 1 1 348973 3 1 115079 1 ...
output:
26541145
result:
ok single line: '26541145'
Test #29:
score: 0
Accepted
time: 15ms
memory: 506644kb
input:
50 3 2 46848 7 2 325883 8 2 117746 15 2 558908 10 2 306170 6 2 64757 7 2 921911 14 2 595053 9 2 165990 12 2 820711 5 2 906949 7 2 58158 7 2 913489 11 2 47146 13 1 850433 11 2 902467 2 1 605115 20 2 18533 17 1 856769 1 1 25566 15 1 572633 15 1 576983 20 1 477172 20 2 305873 1 1 328317 14 1 371795 10 ...
output:
6770719
result:
ok single line: '6770719'
Test #30:
score: 0
Accepted
time: 19ms
memory: 506876kb
input:
50 36 36 625474 36 40 170844 11 33 105709 36 25 235093 36 7 968140 28 6 809875 28 50 36203 32 43 39220 38 3 940083 39 38 340308 32 16 52508 23 2 214852 2 41 66277 24 41 197404 10 45 732983 12 14 281052 47 4 48255 5 6 13242 41 1 288494 35 23 231463 26 8 650910 23 26 948695 22 26 438225 23 11 202784 4...
output:
1999551
result:
ok single line: '1999551'
Test #31:
score: 0
Accepted
time: 27ms
memory: 506696kb
input:
50 4 1 708504 2 1 25812 2 1 929878 2 1 948469 2 1 935630 2 1 320875 1 3 296379 1 1 224548 1 3 260025 4 3 470423 4 3 908625 4 3 326833 4 2 512512 4 3 776079 4 2 119315 1 3 343625 4 2 909172 1 1 540102 3 1 37256 1 1 663274 3 1 316932 3 1 255470 1 1 748057 3 1 468414 3 1 154156 1 1 332272 1 3 989355 1 ...
output:
7441716
result:
ok single line: '7441716'
Test #32:
score: 0
Accepted
time: 15ms
memory: 506712kb
input:
50 3 2 4495 6 5 821747 3 5 513717 3 4 198688 3 5 133200 3 4 562563 3 5 1745 3 2 796324 3 2 121975 3 2 355437 3 2 958986 3 5 348918 3 2 688537 3 5 243544 3 2 281644 3 2 481683 3 4 368178 3 5 44026 2 5 444795 2 1 671577 2 5 480780 2 5 307850 3 5 294000 3 5 506625 3 5 26346 3 5 944155 3 5 721737 2 5 38...
output:
22763424
result:
ok single line: '22763424'
Test #33:
score: 0
Accepted
time: 31ms
memory: 506872kb
input:
50 3 2 114721 1 2 677392 1 2 744163 3 2 911732 3 2 439830 3 2 258881 3 2 99291 3 2 110116 3 2 215025 3 2 752788 3 2 372734 3 3 204575 3 2 172498 1 2 418905 1 2 105379 1 2 924201 1 2 930636 1 2 602435 1 3 383988 1 3 351653 1 3 329123 1 3 983611 1 3 318715 1 3 930735 2 3 755324 1 2 908985 2 3 679748 1...
output:
22851854
result:
ok single line: '22851854'
Test #34:
score: 0
Accepted
time: 16ms
memory: 506836kb
input:
50 4 2 550647 3 3 745046 4 2 82220 3 2 736935 3 2 177500 3 2 701449 3 2 882392 3 2 602036 3 2 347928 3 2 99110 1 2 231974 3 5 324125 1 5 562151 5 5 931140 5 5 608960 5 5 689406 5 5 460786 5 5 341464 5 5 410709 1 5 830629 1 5 450967 1 5 376792 1 5 280917 1 5 184417 1 4 568698 1 5 808410 1 5 834076 1 ...
output:
22938374
result:
ok single line: '22938374'
Test #35:
score: 0
Accepted
time: 35ms
memory: 506644kb
input:
50 8 9 755133 5 9 189393 5 17 937796 5 9 266650 5 17 74215 5 17 727841 13 17 996631 13 17 737562 13 17 992293 13 17 528790 13 17 597865 13 17 657485 13 17 261545 15 17 814769 12 17 608533 15 17 536216 15 17 805518 15 17 453732 15 17 818563 15 17 317048 15 17 323363 15 18 697292 15 18 943783 15 14 22...
output:
19687264
result:
ok single line: '19687264'
Test #36:
score: 0
Accepted
time: 23ms
memory: 506580kb
input:
50 7 40 957293 43 15 397449 7 40 258170 43 40 715363 43 40 463655 43 24 158403 43 40 543726 43 40 289638 43 40 8173 43 40 257572 43 1 852905 43 40 876451 43 11 458823 43 11 231217 43 11 576357 43 11 759595 43 25 562663 43 11 866753 43 2 784767 43 34 720701 43 2 563950 43 34 767462 43 8 384909 43 34 ...
output:
22149389
result:
ok single line: '22149389'
Test #37:
score: 0
Accepted
time: 8ms
memory: 506644kb
input:
50 1 1 401239 1 1 123343 3 2 37948 1 2 928157 3 1 41013 1 1 167678 1 3 453101 1 3 425822 1 3 238620 3 3 650988 2 2 667581 1 1 410007 1 3 411260 1 3 833222 3 2 585366 3 2 194722 3 1 494401 3 2 792153 3 1 208866 2 1 642386 2 2 476443 3 1 808109 3 3 964504 3 3 485383 3 2 521487 1 2 504084 3 2 938384 3 ...
output:
21688534
result:
ok single line: '21688534'
Test #38:
score: 0
Accepted
time: 40ms
memory: 506708kb
input:
50 9 11 584272 3 5 588812 1 5 613136 3 11 198405 1 2 883184 10 6 997395 6 20 273658 7 2 377738 10 2 302431 4 20 900434 1 6 847475 1 5 485816 1 20 321524 6 20 714334 4 20 825231 4 20 634911 3 7 252608 8 11 791546 8 20 763774 3 20 592499 9 2 561750 3 16 339633 10 16 190676 10 11 210456 7 11 167598 7 1...
output:
22970184
result:
ok single line: '22970184'
Test #39:
score: 0
Accepted
time: 16ms
memory: 506604kb
input:
50 2 9 267988 1 27 174660 1 9 488035 2 9 901290 2 9 985392 2 44 580543 1 9 225387 1 1 526158 2 44 42297 1 38 710344 1 16 300532 1 44 118480 1 3 733703 1 13 112641 2 21 194623 2 3 753144 1 50 898603 1 13 515653 1 50 515586 1 50 666673 1 37 629871 1 50 966804 2 37 389067 1 37 236048 2 11 998049 2 11 6...
output:
23928662
result:
ok single line: '23928662'
Test #40:
score: 0
Accepted
time: 16ms
memory: 506660kb
input:
50 3 2 882376 3 2 266382 4 4 171798 2 4 993847 2 2 567089 2 2 956642 2 2 626607 3 2 38198 3 2 542525 3 2 990800 3 3 684058 4 3 761289 4 4 752890 1 3 701272 2 3 288268 4 4 437542 4 2 833483 1 1 621112 1 3 810473 4 4 323428 4 1 901645 1 1 94344 1 4 332503 2 4 813475 1 4 106608 2 4 11046 4 4 212628 2 4...
output:
25256313
result:
ok single line: '25256313'
Subtask #3:
score: 75
Accepted
Test #41:
score: 75
Accepted
time: 43ms
memory: 506644kb
input:
1 200 200 200
output:
200
result:
ok single line: '200'
Test #42:
score: 0
Accepted
time: 8ms
memory: 506872kb
input:
2 10 50 30 60 50 40
output:
70
result:
ok single line: '70'
Test #43:
score: 0
Accepted
time: 28ms
memory: 506708kb
input:
3 1 1 163773 1 2 27521 2 1 169241
output:
360535
result:
ok single line: '360535'
Test #44:
score: 0
Accepted
time: 123ms
memory: 506600kb
input:
500 2 1 801235 2 1 614738 2 1 760372 1 1 547202 1 1 303884 2 1 221978 2 1 249684 2 1 948084 1 1 911025 1 1 471692 1 1 39453 2 2 966453 1 1 223258 1 1 464192 2 2 268354 1 1 769463 1 2 632045 2 1 103860 2 1 556270 2 2 685352 2 1 818313 2 2 979672 1 2 159488 2 2 396442 1 2 868424 1 1 702336 1 1 347194 ...
output:
121789762
result:
ok single line: '121789762'
Test #45:
score: 0
Accepted
time: 129ms
memory: 506832kb
input:
500 1 2 401574 1 2 28027 1 2 140511 1 2 763315 1 1 98003 2 2 913114 2 1 592527 2 2 804999 2 3 912208 1 2 595632 1 3 930709 1 1 198869 2 2 837922 2 1 51494 1 3 4602 2 3 606683 1 1 998463 1 2 891766 1 2 881494 2 3 413628 2 2 973149 1 1 773132 1 3 493088 1 1 878639 2 1 711702 2 2 385508 1 3 685396 2 1 ...
output:
116841275
result:
ok single line: '116841275'
Test #46:
score: 0
Accepted
time: 110ms
memory: 506704kb
input:
500 1 1 526482 3 2 407920 1 3 370384 2 2 929488 2 1 310193 2 2 745094 2 2 766465 2 2 628681 1 3 78833 2 2 459164 1 3 494513 1 2 432040 1 1 208939 1 1 161729 1 2 750475 3 3 734196 3 3 212091 2 3 378657 3 1 230130 1 2 931883 1 3 266994 1 3 533946 3 1 479783 2 1 770779 2 1 681964 3 1 689495 2 1 991012 ...
output:
19595795
result:
ok single line: '19595795'
Test #47:
score: 0
Accepted
time: 128ms
memory: 506584kb
input:
500 303 233 243528 369 435 604060 161 253 712179 221 391 255198 90 47 208016 277 404 930525 394 90 467205 492 7 81567 440 410 22517 82 310 823630 297 253 371525 449 353 573839 228 476 519143 426 30 283932 105 476 583991 454 376 134079 176 9 973992 419 136 611014 120 382 992629 440 84 907113 298 258 ...
output:
712179
result:
ok single line: '712179'
Test #48:
score: 0
Accepted
time: 120ms
memory: 506716kb
input:
500 1 1 995252 2 1 70211 2 2 774064 1 1 948063 2 2 114289 2 2 697936 1 1 3635 2 1 506179 2 2 824811 1 1 851471 1 2 490997 2 1 49683 1 2 147997 1 1 126137 1 1 162933 1 1 385563 1 1 324810 2 1 401187 2 2 576073 1 2 530171 1 2 928743 2 1 167791 1 2 710105 2 2 595757 2 1 755167 1 1 234624 2 1 62534 2 2 ...
output:
122629142
result:
ok single line: '122629142'
Test #49:
score: 0
Accepted
time: 123ms
memory: 506836kb
input:
500 2 1 162051 2 1 193020 1 3 170321 2 3 102345 2 2 177095 3 3 653445 2 3 141191 2 3 206232 3 1 531751 3 2 362060 3 2 525819 3 1 325054 1 1 314404 1 3 881309 1 1 120815 2 3 696562 2 3 641861 3 1 101714 3 1 409463 3 3 469794 1 3 127283 1 3 18147 3 3 566941 2 2 352581 3 2 499495 1 3 698829 1 2 408641 ...
output:
12510591
result:
ok single line: '12510591'
Test #50:
score: 0
Accepted
time: 112ms
memory: 506708kb
input:
500 7 11 327868 1 18 558298 4 11 874606 18 11 729889 16 16 694369 9 14 340992 13 18 148539 3 10 82773 5 16 43871 4 16 598172 14 17 326247 9 12 310620 17 14 605274 16 1 451894 1 11 577994 13 18 228013 17 8 96521 19 10 334064 3 16 982560 7 15 380767 1 10 218419 7 1 33788 15 8 851475 13 11 631540 13 6 ...
output:
1932363
result:
ok single line: '1932363'
Test #51:
score: 0
Accepted
time: 116ms
memory: 506948kb
input:
500 2 3 289031 3 3 734825 3 3 172648 3 1 711217 3 1 392887 3 1 643263 3 1 551288 3 1 259586 1 1 567316 2 2 818046 2 3 474865 1 3 468730 2 3 364529 3 3 98272 3 3 729529 3 3 211831 3 3 569862 3 3 504270 3 1 689287 3 3 737679 3 1 93764 3 1 98896 2 1 18828 2 1 709204 2 1 926964 1 1 517480 2 1 840213 2 1...
output:
88577744
result:
ok single line: '88577744'
Test #52:
score: 0
Accepted
time: 124ms
memory: 506708kb
input:
500 2 4 307969 2 3 219932 2 1 47543 1 3 781400 1 3 845106 1 3 875471 1 4 362876 1 4 996518 2 4 768014 2 4 323630 1 4 258000 1 4 684158 1 3 3925 1 4 364402 1 2 710964 1 1 297941 1 1 986612 1 3 850081 1 3 458066 1 3 440563 1 1 534930 2 1 122561 2 1 435478 1 1 840153 2 1 268033 2 1 617489 2 3 618438 1 ...
output:
219076219
result:
ok single line: '219076219'
Test #53:
score: 0
Accepted
time: 131ms
memory: 506648kb
input:
500 2 4 32176 1 3 655697 3 3 573891 3 3 144558 2 3 163912 2 3 791125 2 3 163509 2 3 725061 2 3 921918 2 3 595996 2 3 744754 2 3 488051 2 3 672326 2 3 769145 2 3 411156 2 3 958767 1 3 104716 2 2 577257 1 3 852606 1 3 776963 1 3 241707 1 3 673317 1 3 831431 1 3 85871 1 3 186779 4 3 491235 4 3 220466 1...
output:
124501424
result:
ok single line: '124501424'
Test #54:
score: 0
Accepted
time: 116ms
memory: 506584kb
input:
500 1 1 101628 2 2 829342 2 1 965851 2 1 339802 2 2 683994 4 2 924228 3 2 100886 3 2 203851 1 2 691905 3 2 702760 1 2 365389 1 4 465361 2 2 296857 1 4 719471 1 2 882194 1 3 600619 4 3 884896 4 3 267715 4 3 422843 4 3 918880 4 3 453777 2 3 916750 2 3 831735 2 3 49417 3 3 663462 3 3 461890 4 3 359349 ...
output:
111982371
result:
ok single line: '111982371'
Test #55:
score: 0
Accepted
time: 132ms
memory: 506548kb
input:
500 5 2 981799 3 2 33226 5 4 204482 5 4 247926 5 4 818433 1 4 587431 5 4 529415 5 4 330540 5 4 330676 4 4 644383 5 2 610165 4 2 400104 5 2 765830 3 2 879172 1 2 234640 3 2 17499 5 2 486723 5 2 915005 3 2 459459 5 2 735163 3 2 321770 3 1 607538 3 1 911097 3 1 133304 2 4 643000 2 1 302311 2 4 408148 2...
output:
75106284
result:
ok single line: '75106284'
Test #56:
score: 0
Accepted
time: 120ms
memory: 506872kb
input:
500 267 269 614263 174 269 469369 172 269 72617 172 269 856730 114 269 31314 114 22 326640 114 458 744781 471 458 840348 471 495 468949 471 495 968854 471 283 947142 471 240 679692 471 317 682387 471 332 412908 471 235 770065 471 235 788312 471 183 401337 471 499 213247 471 19 7497 471 19 987705 489...
output:
12933914
result:
ok single line: '12933914'
Test #57:
score: 0
Accepted
time: 119ms
memory: 506704kb
input:
500 3 3 960776 3 2 491716 3 3 229921 2 3 150638 2 1 418102 3 1 456757 2 1 762518 2 1 149023 2 1 368526 2 1 43187 2 1 560395 2 2 298438 2 3 725640 2 2 986029 2 2 578723 2 2 249624 1 3 496322 2 2 56517 1 3 291489 1 2 90930 1 3 628794 2 3 105579 1 3 59117 1 1 322347 2 3 139737 1 3 982243 1 2 890977 1 3...
output:
220664110
result:
ok single line: '220664110'
Test #58:
score: 0
Accepted
time: 143ms
memory: 506876kb
input:
500 5 2 739948 5 4 70018 2 2 839229 2 4 954685 2 1 312067 5 1 362018 3 1 839212 3 1 802511 3 5 395584 4 5 176199 3 5 565527 3 5 527801 3 1 952193 4 1 875423 3 1 700438 4 1 319873 4 2 611140 4 1 82132 4 1 57282 4 4 318233 4 4 232392 4 1 601103 3 4 77219 3 4 966461 3 4 647944 2 4 290869 3 4 824747 2 4...
output:
235637943
result:
ok single line: '235637943'
Test #59:
score: 0
Accepted
time: 127ms
memory: 506868kb
input:
500 4 3 857478 18 3 400703 3 2 459108 4 3 825240 4 3 281293 18 3 144280 3 2 777506 11 3 842953 15 3 653212 3 3 333239 19 3 814769 19 2 158790 17 2 296101 15 2 626614 15 2 305153 16 2 383981 16 2 637661 18 2 970839 16 1 579465 16 1 246747 16 2 720752 16 2 55937 15 3 588699 12 1 227130 6 2 830927 6 3 ...
output:
210083838
result:
ok single line: '210083838'
Test #60:
score: 0
Accepted
time: 116ms
memory: 506948kb
input:
500 11 19 852348 16 19 28373 17 19 828769 17 34 251624 11 34 312879 11 21 805590 50 21 274681 32 19 72530 32 21 210218 50 5 430440 10 5 586722 10 33 252642 35 5 600193 7 5 259267 10 5 762616 10 33 161406 42 5 99103 2 5 421865 42 33 777627 42 50 96451 42 33 170154 42 24 507793 42 23 951289 2 5 721708...
output:
189738984
result:
ok single line: '189738984'
Test #61:
score: 0
Accepted
time: 127ms
memory: 506700kb
input:
500 296 38 456501 296 408 735440 471 408 949216 471 185 336110 471 408 419831 471 494 265408 471 183 917420 171 185 736687 171 394 547544 171 394 438304 54 394 60615 232 394 214249 54 226 918499 34 226 528791 169 226 13068 169 181 781289 121 226 617025 176 393 13290 176 249 203500 176 181 32566 176 ...
output:
253510866
result:
ok single line: '253510866'
Test #62:
score: 0
Accepted
time: 139ms
memory: 506652kb
input:
500 486 350 715755 159 350 321054 426 350 815521 42 9 991893 38 352 234898 495 350 259647 495 79 385676 495 9 78386 38 271 303093 445 9 761322 445 352 442634 38 56 388219 38 223 304861 321 154 282019 321 56 802657 321 223 152940 356 56 513569 356 108 841066 36 108 573739 378 352 770006 194 352 53429...
output:
221838211
result:
ok single line: '221838211'
Test #63:
score: 0
Accepted
time: 298ms
memory: 506716kb
input:
500 1 1 38635 1 1 378764 1 1 710302 1 1 532310 1 1 869307 1 1 153715 1 1 35851 1 1 73916 1 1 914563 1 1 221415 1 1 668886 1 1 661377 1 1 918611 1 1 966843 1 1 737131 1 1 216635 1 1 320919 1 1 540673 1 1 128697 1 1 200452 1 1 612892 1 1 542515 1 1 979450 1 1 339618 1 1 539805 1 1 253325 1 1 408305 1 ...
output:
251531074
result:
ok single line: '251531074'
Test #64:
score: 0
Accepted
time: 236ms
memory: 506588kb
input:
500 1 1 70840 1 1 401475 1 1 801453 1 1 855200 1 1 43881 1 1 151278 1 1 577002 1 1 290143 1 1 488583 1 1 294265 1 1 296829 1 1 219545 1 1 720771 1 1 188400 1 1 679902 1 1 663488 1 1 162292 1 1 527460 1 1 751113 1 1 494232 1 1 461224 1 1 266392 1 1 559000 1 1 764545 1 1 411409 1 1 160163 1 1 629654 1...
output:
261906911
result:
ok single line: '261906911'
Test #65:
score: 0
Accepted
time: 194ms
memory: 506704kb
input:
500 1 1 152336 1 1 963009 1 1 416299 1 1 625459 1 1 159573 1 1 403914 1 1 55304 1 1 831581 1 1 331492 1 1 694835 1 1 886798 1 1 323231 1 1 182512 1 1 261617 1 1 62244 1 1 740132 1 1 238105 1 1 936419 1 1 900688 1 1 12380 1 1 825039 1 1 60555 1 1 182776 1 1 952866 1 1 751225 1 1 706238 1 1 189625 1 1...
output:
253057806
result:
ok single line: '253057806'
Test #66:
score: 0
Accepted
time: 168ms
memory: 506868kb
input:
500 1 1 856624 1 1 874836 1 1 121375 1 1 937285 1 1 809817 1 1 452916 1 1 5458 1 1 52108 1 1 729887 1 1 789381 1 1 402562 1 1 725452 1 1 771739 1 1 848845 1 1 269203 1 1 629161 1 1 4236 1 1 813216 1 1 484226 1 1 179939 1 1 273067 1 1 28222 1 1 45 1 1 815181 1 1 795478 1 1 830951 1 1 739287 1 1 34180...
output:
199796411
result:
ok single line: '199796411'
Test #67:
score: 0
Accepted
time: 167ms
memory: 506700kb
input:
500 1 1 17137 1 1 474004 1 1 212811 1 1 124892 1 1 156837 1 1 433222 1 1 981858 1 1 682237 1 1 417319 1 1 687279 1 1 765752 1 1 622002 1 1 265660 1 1 827878 1 1 453060 1 1 144336 1 1 528506 1 1 313970 1 1 797577 1 1 375928 1 1 797687 1 1 726588 1 1 841830 1 1 487357 1 1 553334 1 1 30870 1 1 611305 1...
output:
165411620
result:
ok single line: '165411620'
Extra Test:
score: 0
Extra Test Passed