QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#200291 | #7343. Bicycle Race | Delay_for_five_minutes# | AC ✓ | 276ms | 14876kb | C++14 | 3.3kb | 2023-10-04 16:16:35 | 2023-10-04 16:16:36 |
Judging History
answer
#include<bits/stdc++.h>
#define maxn 100005
typedef std::tuple<int,int,int> tu;
typedef std::pair<int,int> pr;
std::vector< std::pair<int,pr> > T[maxn];
std::pair<int,pr> mx[maxn];
std::pair<int,int> t1[maxn], t2[maxn];
bool check(pr A, pr B) {
return A.first != B.first && A.first != B.second && A.second != B.first && A.second != B.second;
}
int getn(std::pair<int,int> p, int Y) {
if (p.first == Y) {
return p.second;
}
else if (p.second == Y) {
return p.first;
}
else return 0;
}
int ans[maxn];
void solve(int P,int x,int y,int z,int val) {
if (P == 1) {
mx[x] = std::max(mx[x],{val,{y,z}});
}
if (P == 2) {
if (check(mx[x].second,{y,z})) {
ans[x] = std::max(ans[x], val + mx[x].first);
}
}
if (P == 3) {
int X = mx[x].second.first, Y = mx[x].second.second;
int now = getn({y,z},Y);
if (now == X || now == 0) {
return ;
}
if (val > t1[x].first) t2[x] = t1[x], t1[x] = {val, now};
else if (val > t2[x].first) t2[x] = {val, now};
}
if (P == 4){
int X = mx[x].second.first, Y = mx[x].second.second;
int now = getn({y,z},X);
if (now == Y || now == 0) {
return ;
}
int newval = (now == t1[x].second ? t2[x].first : t1[x].first);
if (newval == 0) return;
ans[x] = std::max(ans[x],val + newval);
}
}
void get_triangles(int n,std::vector<tu>& eg) {
std::vector< pr > e[maxn];
int d[maxn],ed[maxn];
memset(d,0,sizeof d);
memset(ed,0,sizeof ed);
for(auto v : eg) {
d[std::get<1>(v)]++;
}
for(auto v : eg) {
int x = std::get<0>(v), y = std::get<1>(v);
if (std::make_pair(d[x], x) > std::make_pair(d[y], y)) {
std::swap(x,y);
}
e[x].push_back({y,std::get<2>(v)});
}
for(int P = 1; P <= 4; P++) {
for(int u = 1; u <= n; u++) {
for(auto v : e[u]) {
ed[v.first] = v.second;
}
for(auto v : e[u]) {
for(auto w : e[v.first]) {
if (ed[w.first] > 0) {
int x = v.first, y = w.first, z = u, val = v.second + w.second + ed[w.first];
solve(P,x,y,z,val);
solve(P,y,x,z,val);
solve(P,z,x,y,val);
}
}
}
for(auto v : e[u]) {
ed[v.first] = 0;
}
}
}
}
/*
int calc(std::vector< std::pair<int,pr> >& vec) {
std::pair<int,pr> mx = {0,{0,0}};
for(auto i : vec) if (i > mx) {
mx = i;
}
int ans = -1;
for(auto i : vec) if (check(i.second,mx.second)) {
ans = std::max(ans,i.first + mx.first);
}
std::pair<int,int> t1 = {0,0}, t2 = {0,0};
int x = mx.second.first, y = mx.second.second;
for(auto i : vec) {
int now = getn(i.second,y);
if (now == x || now == 0) {
continue;
}
if (i.first > t1.first) t2 = t1, t1 = {i.first, now};
else if (i.first > t2.first) t2 = {i.first, now};
}
for(auto i : vec) {
int now = getn(i.second, x);
if (now == y || now == 0) {
continue;
}
int val = (now == t1.second ? t2.first : t1.first);
if (val == 0) continue;
ans = std::max(ans, i.first + val);
}
return ans;
}
*/
int main() {
std::ios::sync_with_stdio(0);std::cin.tie(0);
// freopen("in.txt","r",stdin);
int n,m;
std::cin >> n >> m;
std::vector<tu> eg;
for(int i=1;i<=m;i++) {
int x,y,z;
std::cin >> x >> y >> z;
eg.push_back({x,y,z});
}
for(int i = 1;i <= n; i++) {
ans[i] = -1;
}
get_triangles(n,eg);
int Ans = -1;
for(int i = 1;i <= n; i++) {
Ans = std::max(Ans,ans[i]);
}
std::cout << Ans << std::endl;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 9108kb
input:
6 9 1 2 3 2 3 1 3 4 2 4 5 1 3 5 7 2 5 2 1 5 3 4 6 2 5 6 1
output:
18
result:
ok 1 number(s): "18"
Test #2:
score: 0
Accepted
time: 2ms
memory: 11136kb
input:
6 6 1 3 2 1 2 2 2 3 4 3 4 1 3 6 6 1 4 8
output:
-1
result:
ok 1 number(s): "-1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 9668kb
input:
5 6 1 4 2 1 3 6 5 2 10 3 2 4 4 2 1 5 4 7
output:
-1
result:
ok 1 number(s): "-1"
Test #4:
score: 0
Accepted
time: 2ms
memory: 10088kb
input:
5 10 2 1 9 3 1 4 3 2 3 4 1 5 4 2 9 4 3 9 5 1 5 5 2 6 5 3 10 5 4 1
output:
43
result:
ok 1 number(s): "43"
Test #5:
score: 0
Accepted
time: 0ms
memory: 9272kb
input:
5 10 2 1 9 3 1 8 3 2 8 4 1 1 4 2 2 4 3 8 5 1 10 5 2 1 5 3 10 5 4 3
output:
46
result:
ok 1 number(s): "46"
Test #6:
score: 0
Accepted
time: 0ms
memory: 10664kb
input:
5 9 1 3 4 4 1 10 1 5 9 5 2 9 3 5 9 2 3 7 5 4 1 2 1 7 2 4 1
output:
45
result:
ok 1 number(s): "45"
Test #7:
score: 0
Accepted
time: 0ms
memory: 10756kb
input:
5 8 2 1 10 5 2 5 1 3 7 3 5 8 3 2 5 2 4 6 4 3 5 4 5 6
output:
41
result:
ok 1 number(s): "41"
Test #8:
score: 0
Accepted
time: 0ms
memory: 10848kb
input:
200 2000 182 97 91166 25 11 25393 179 58 43378 77 41 75588 139 96 94145 135 56 4609 190 159 47293 100 30 33854 21 132 93072 174 135 93547 144 137 81216 199 102 68247 89 155 53788 83 25 64607 166 179 44534 101 3 1474 37 106 57970 187 41 19892 16 76 32024 182 13 32061 72 69 5823 187 185 13918 151 86 3...
output:
552426
result:
ok 1 number(s): "552426"
Test #9:
score: 0
Accepted
time: 3ms
memory: 10836kb
input:
400 4000 102 372 24346 360 153 94255 272 316 33427 215 71 52304 368 202 60854 350 206 16796 32 372 31489 109 14 95840 163 71 79896 330 393 95303 324 110 13216 197 341 69668 54 241 46100 222 246 67388 140 13 539 272 79 22065 389 221 81398 187 122 60482 198 352 4291 196 14 18220 215 93 64141 336 54 54...
output:
545402
result:
ok 1 number(s): "545402"
Test #10:
score: 0
Accepted
time: 4ms
memory: 10436kb
input:
600 6000 270 248 73879 94 543 63116 118 174 23476 152 301 12668 597 557 27564 566 156 28983 322 585 15685 319 598 41474 506 411 50369 334 450 80707 103 83 61569 195 333 71089 219 576 54764 409 18 70169 115 296 72896 92 155 42655 542 537 4827 387 202 1071 209 15 4380 511 165 22459 485 571 94537 570 2...
output:
545966
result:
ok 1 number(s): "545966"
Test #11:
score: 0
Accepted
time: 4ms
memory: 10768kb
input:
800 8000 391 123 23412 629 133 31977 411 31 13525 489 131 89384 427 512 94273 29 506 24818 564 397 99881 528 382 3460 448 702 20841 290 156 82464 235 56 9922 192 772 88862 784 63 47076 148 591 72950 490 531 45253 263 231 63246 295 453 44608 234 683 58012 562 56 32475 671 464 90539 454 237 97128 635 ...
output:
537316
result:
ok 1 number(s): "537316"
Test #12:
score: 0
Accepted
time: 2ms
memory: 10396kb
input:
900 9000 751 713 98178 420 281 8232 734 560 50374 234 645 19566 641 65 77628 537 681 89087 561 4 33803 457 274 26277 367 372 56077 816 485 16990 425 42 67747 543 144 89573 43 230 93232 441 701 66164 801 772 31431 773 392 73541 771 535 6323 634 271 20131 429 870 52257 54 265 33619 425 148 84463 285 6...
output:
543761
result:
ok 1 number(s): "543761"
Test #13:
score: 0
Accepted
time: 2ms
memory: 9308kb
input:
1000 10000 474 791 31535 814 802 77941 268 530 73504 935 202 16680 294 563 90749 295 865 28879 881 407 92656 170 489 69207 647 539 16716 588 994 32698 450 999 67004 450 85 62626 88 759 97603 375 910 48465 855 380 62615 581 791 48023 692 533 10312 249 752 93019 229 570 80407 135 31 24826 158 458 2555...
output:
535602
result:
ok 1 number(s): "535602"
Test #14:
score: 0
Accepted
time: 268ms
memory: 13040kb
input:
500 100000 2 1 54424 3 1 48973 3 2 86095 4 1 76564 4 2 82172 4 3 86663 5 1 24522 5 2 37933 5 3 67602 5 4 17497 6 1 53084 6 2 41172 6 3 52523 6 4 91108 6 5 84953 7 1 594 7 2 61541 7 3 90638 7 4 34896 7 5 73592 7 6 62931 8 2 72346 8 5 16373 8 7 95438 9 1 19930 9 2 89438 9 3 2195 9 4 71744 9 5 1168 9 6...
output:
596558
result:
ok 1 number(s): "596558"
Test #15:
score: 0
Accepted
time: 270ms
memory: 11648kb
input:
500 100000 2 1 2692 3 2 10621 4 1 60135 4 2 56741 5 1 66724 5 2 46777 5 3 72456 5 4 41383 6 1 24952 6 2 86 6 3 50877 6 4 14549 6 5 12700 7 1 81676 7 2 72840 7 3 96493 7 5 75581 7 6 97962 8 2 35448 8 3 48547 8 4 38631 8 5 82104 8 6 23747 8 7 36514 9 1 48937 9 2 11326 9 3 69303 9 4 82858 9 5 63680 9 6...
output:
597511
result:
ok 1 number(s): "597511"
Test #16:
score: 0
Accepted
time: 24ms
memory: 11940kb
input:
10000 100000 2188 6529 2 2188 7677 2 2188 7805 2 2188 9308 2 6529 7677 2 7805 9308 2 9599 3197 1 1786 3787 1 3578 3237 1 4859 8184 1 5300 3418 1 8450 499 1 8636 8041 1 8387 362 1 2902 1224 1 4847 1610 1 1619 3629 1 1694 5617 1 12 9337 1 4295 2005 1 6636 8226 1 9375 8605 1 9768 4222 1 2699 3741 1 537...
output:
12
result:
ok 1 number(s): "12"
Test #17:
score: 0
Accepted
time: 28ms
memory: 13264kb
input:
10000 100000 4562 1795 2 4562 2711 2 4562 3418 2 4562 5389 2 1795 2711 2 3418 5389 2 5748 3255 1 4941 6175 1 4685 7745 1 9064 5340 1 8299 8951 1 6060 4991 1 8897 6685 1 3518 4129 1 1106 6438 1 7695 3588 1 5920 5482 1 3070 9224 1 2582 5878 1 6686 8890 1 4017 4816 1 1282 4041 1 4601 436 1 2500 1638 1 ...
output:
12
result:
ok 1 number(s): "12"
Test #18:
score: 0
Accepted
time: 28ms
memory: 11992kb
input:
10000 100000 6937 2540 2 6937 2679 2 6937 6749 2 6937 7929 2 2540 2679 2 6749 7929 2 1897 3312 1 1744 4915 1 5791 8605 1 3268 6145 1 7651 4484 1 22 9483 1 9159 5330 1 8649 7897 1 9309 1651 1 543 5566 1 222 3688 1 4447 6479 1 1504 8771 1 9076 2126 1 7750 5054 1 3189 9477 1 3082 6651 1 2300 3183 1 315...
output:
12
result:
ok 1 number(s): "12"
Test #19:
score: 0
Accepted
time: 3ms
memory: 10656kb
input:
10000 29992 1 2 1 9997 1 1 9998 1 1 2 3 1 9997 2 1 9998 2 1 3 4 1 9997 3 1 9998 3 1 4 5 1 9997 4 1 9998 4 1 5 6 1 9997 5 1 9998 5 1 6 7 1 9997 6 1 9998 6 1 7 8 1 9997 7 1 9998 7 1 8 9 1 9997 8 1 9998 8 1 9 10 1 9997 9 1 9998 9 1 10 11 1 9997 10 1 9998 10 1 11 12 1 9997 11 1 9998 11 1 12 13 1 9997 12...
output:
100302
result:
ok 1 number(s): "100302"
Test #20:
score: 0
Accepted
time: 0ms
memory: 9592kb
input:
10000 9999 4324 1 16290 4324 2 71785 4324 3 14388 4324 4 8277 4324 5 13642 4324 6 51181 4324 7 26874 4324 8 209 4324 9 38258 4324 10 6368 4324 11 35018 4324 12 17125 4324 13 36915 4324 14 13046 4324 15 16002 4324 16 33080 4324 17 60494 4324 18 35992 4324 19 95076 4324 20 71293 4324 21 81397 4324 22 ...
output:
-1
result:
ok 1 number(s): "-1"
Test #21:
score: 0
Accepted
time: 9ms
memory: 13704kb
input:
100000 99999 58495 1 85101 58495 2 97799 58495 3 80649 58495 4 34353 58495 5 87833 58495 6 34007 58495 7 83178 58495 8 67343 58495 9 53763 58495 10 62046 58495 11 59552 58495 12 58790 58495 13 68682 58495 14 98674 58495 15 75531 58495 16 46217 58495 17 59944 58495 18 28555 58495 19 26879 58495 20 69...
output:
-1
result:
ok 1 number(s): "-1"
Test #22:
score: 0
Accepted
time: 0ms
memory: 12420kb
input:
10000 9999 9886 6478 77145 6478 1002 22410 1002 7725 6914 7725 5151 88423 5151 4615 90706 4615 276 88418 276 651 31102 651 3396 17550 3396 7197 47149 7197 1517 57637 1517 2551 26825 2551 1399 97972 1399 3669 37991 3669 1030 41452 1030 7296 58441 7296 7481 50595 7481 7754 56414 7754 6401 80568 6401 3...
output:
-1
result:
ok 1 number(s): "-1"
Test #23:
score: 0
Accepted
time: 20ms
memory: 13832kb
input:
100000 99999 99697 62499 17359 62499 65369 84138 65369 38767 3834 38767 49004 92149 49004 41714 87272 41714 25240 48039 25240 40929 14513 40929 74271 5375 74271 97963 48998 97963 88205 97714 88205 44238 78637 44238 73947 33673 73947 88038 12339 88038 34453 65123 34453 94958 19816 94958 48075 10067 4...
output:
-1
result:
ok 1 number(s): "-1"
Test #24:
score: 0
Accepted
time: 0ms
memory: 9780kb
input:
100 197 60 98 1617 98 3 35314 98 8 32959 98 67 38073 8 46 43213 3 31 95978 46 64 29598 8 12 83873 31 74 37874 64 16 69419 8 100 8340 8 81 32173 8 75 36960 100 14 87509 74 84 76405 46 91 52507 16 5 76978 81 41 10067 41 71 51697 14 99 1009 75 9 49341 5 35 41721 9 88 26833 100 79 8899 12 15 86030 31 76...
output:
509330
result:
ok 1 number(s): "509330"
Test #25:
score: 0
Accepted
time: 3ms
memory: 10500kb
input:
1000 1997 657 656 12140 657 103 50769 656 608 43803 103 457 76249 608 620 90055 657 222 58123 656 331 97872 331 930 58126 103 90 90000 656 987 97497 331 793 66164 457 690 43735 656 929 32424 222 205 54505 103 124 69291 793 274 59946 103 333 94914 205 831 90318 656 78 78344 930 267 11779 274 606 2928...
output:
547289
result:
ok 1 number(s): "547289"
Test #26:
score: 0
Accepted
time: 0ms
memory: 10292kb
input:
10000 19997 9886 6478 22410 9886 1002 88423 1002 7725 88418 1002 5151 17550 7725 4615 57637 5151 276 97972 276 651 41452 4615 3396 50595 1002 7197 80568 6478 1517 46843 7725 2551 11832 4615 1399 32622 6478 3669 13880 4615 1030 96284 1030 7296 27398 5151 7481 33479 276 7754 10690 9886 6401 20178 2551...
output:
580069
result:
ok 1 number(s): "580069"
Test #27:
score: 0
Accepted
time: 31ms
memory: 14452kb
input:
50000 99997 46703 3202 33177 3202 23493 62517 23493 17355 31588 17355 11839 13616 11839 40451 67170 17355 19209 39727 46703 41048 46860 40451 12518 58874 46703 24389 57287 40451 41038 57317 23493 34738 13193 11839 1865 32227 12518 44478 5445 40451 36110 58217 19209 20878 24949 1865 13239 40449 46703...
output:
589408
result:
ok 1 number(s): "589408"
Test #28:
score: 0
Accepted
time: 26ms
memory: 13216kb
input:
10000 100000 2188 7677 56529 9308 7805 9599 3197 1786 43787 3578 3237 24859 8184 5300 43418 8450 499 28636 8041 8387 362 2902 1224 44847 1610 1619 3629 1694 5617 20012 9337 4295 12005 6636 8226 89375 8605 9768 44222 2699 3741 5371 6395 8180 86687 5906 1787 21079 7613 9168 19101 8533 3163 13727 5607 ...
output:
506291
result:
ok 1 number(s): "506291"
Test #29:
score: 0
Accepted
time: 29ms
memory: 13196kb
input:
10000 100000 4562 5389 62711 1795 3418 75748 3255 4941 6175 4685 7745 59064 5340 8299 28951 6060 4991 28897 6685 3518 34129 1106 6438 87695 3588 5920 25482 3070 9224 62582 5878 6686 78890 4017 4816 81282 4041 4601 40436 2500 1638 57437 7472 9525 52759 5356 9641 70526 5224 3872 30968 3429 7904 9317 2...
output:
508401
result:
ok 1 number(s): "508401"
Test #30:
score: 0
Accepted
time: 30ms
memory: 12968kb
input:
10000 100000 6937 6749 52540 7929 2679 41897 3312 1744 84915 5791 8605 93268 6145 7651 14484 22 9483 29159 5330 8649 67897 9309 1651 30543 5566 222 63688 4447 6479 21504 8771 9076 62126 7750 5054 73189 9477 3082 36651 2300 3183 93152 8550 4518 18832 8455 7495 36326 2836 2225 59188 1974 2645 21260 12...
output:
500379
result:
ok 1 number(s): "500379"
Test #31:
score: 0
Accepted
time: 25ms
memory: 12640kb
input:
10000 100000 9311 4461 58722 4063 8292 24398 9721 4898 63656 6898 3114 27472 3301 650 18 7632 3974 29421 3975 7428 1664 3865 6865 73390 7544 875 85541 5823 85 64073 5311 1467 29011 5132 1644 48744 4913 7915 16514 2101 4728 28866 9628 5862 84904 1554 5349 85774 6800 577 87408 518 7386 33202 5970 9385...
output:
510273
result:
ok 1 number(s): "510273"
Test #32:
score: 0
Accepted
time: 21ms
memory: 13404kb
input:
10000 100000 1686 2173 64903 197 7553 90546 9778 1701 26044 8005 7622 78029 4105 2 85551 1594 8466 29683 2619 2560 35431 2069 2078 16238 3170 5176 23747 7200 7340 6643 1852 3857 12248 2513 1882 40651 349 6396 12728 1901 6273 64580 4354 7207 34624 4652 9555 51573 4412 5282 15628 9062 2126 28793 640 2...
output:
473249
result:
ok 1 number(s): "473249"
Test #33:
score: 0
Accepted
time: 30ms
memory: 13688kb
input:
100000 100000 55014 67630 23663 64814 69836 34133 18511 29905 29415 13107 16374 24309 77099 70750 41552 50700 3302 37791 44537 47549 67540 21629 19945 84008 70178 67252 21914 25920 71421 11781 24471 75415 50870 12807 93987 39191 56052 13019 14946 41356 822 70077 35016 31968 91684 38198 156 10078 969...
output:
-1
result:
ok 1 number(s): "-1"
Test #34:
score: 0
Accepted
time: 30ms
memory: 14876kb
input:
100000 100000 47388 25342 29844 10948 65449 282 84920 76708 8155 44213 60882 58513 7904 80102 27085 78310 47793 38052 93182 42680 1308 26185 35158 43207 12156 91553 43767 83649 48676 54350 31012 57805 34107 40188 74225 14746 51488 81500 11161 81157 72367 5791 46094 53313 57756 1297 8010 75878 34524 ...
output:
-1
result:
ok 1 number(s): "-1"
Test #35:
score: 0
Accepted
time: 102ms
memory: 12632kb
input:
1000 100000 4 1 11282 7 4 42863 8 6 80688 8 7 91894 9 1 8949 9 2 13061 9 4 99528 9 6 13364 9 8 234 10 3 69527 10 4 36516 10 7 77970 11 2 56937 12 2 77574 13 1 29639 13 3 59496 13 9 4717 14 8 2917 14 12 34851 15 1 18858 15 2 8410 15 3 90593 15 6 91745 15 7 8124 15 13 51702 16 7 78766 16 8 85004 16 15...
output:
593195
result:
ok 1 number(s): "593195"
Test #36:
score: 0
Accepted
time: 104ms
memory: 12652kb
input:
1000 100000 2 1 36272 7 2 65478 10 2 70023 10 4 80549 10 6 70513 11 4 66796 11 5 65632 11 6 8003 12 4 46750 12 10 64892 13 5 76839 13 7 75486 13 9 89664 14 5 60441 15 10 35756 15 14 93570 16 9 37099 16 13 3786 16 14 94510 17 5 16823 17 6 37802 17 8 35089 17 9 76207 17 11 80814 17 13 31168 17 15 2513...
output:
595197
result:
ok 1 number(s): "595197"
Test #37:
score: 0
Accepted
time: 276ms
memory: 12632kb
input:
500 100000 2 1 54948 3 1 64993 3 2 15439 4 1 95069 4 3 83025 5 1 14715 5 2 74190 5 3 48595 5 4 29414 6 1 48606 6 2 61053 6 3 26299 6 5 88246 7 1 22990 7 2 19434 7 3 37533 7 5 60438 7 6 41296 8 1 89130 8 3 97878 8 5 48918 8 7 21127 9 1 94307 9 2 6520 9 3 35885 9 6 15572 9 8 41547 10 1 33226 10 2 1363...
output:
598108
result:
ok 1 number(s): "598108"
Test #38:
score: 0
Accepted
time: 264ms
memory: 11476kb
input:
500 100000 2 1 64934 3 2 54716 4 2 26135 4 3 2762 5 1 85004 5 2 72302 5 3 26967 6 1 62467 6 2 83217 6 3 76036 7 1 24432 7 2 64299 7 3 11686 7 4 67990 7 5 90790 7 6 70550 8 1 25981 8 2 79187 8 3 34189 8 4 3714 8 5 5815 8 6 24195 8 7 2448 9 1 44754 9 2 23360 9 4 35513 9 5 79085 9 6 3912 9 7 99654 9 8 ...
output:
597700
result:
ok 1 number(s): "597700"
Test #39:
score: 0
Accepted
time: 268ms
memory: 11908kb
input:
500 100000 2 1 6231 3 1 52169 4 1 10499 4 2 94133 5 1 87561 5 2 42015 5 3 82904 5 4 74801 6 1 34171 6 2 58493 6 3 94831 6 4 9361 6 5 79079 7 1 36446 7 2 6155 7 3 69159 7 4 33251 7 5 22567 7 6 46473 8 1 90602 8 2 7097 8 3 58556 8 4 54259 8 5 54788 8 6 93729 8 7 5178 9 1 74124 9 2 54317 9 3 2204 9 4 5...
output:
596646
result:
ok 1 number(s): "596646"
Test #40:
score: 0
Accepted
time: 265ms
memory: 12604kb
input:
500 100000 2 1 33981 3 1 51102 3 2 77173 4 1 13637 4 3 55155 5 2 64550 5 3 51303 5 4 60443 6 1 79982 6 2 80915 6 3 51427 6 5 6493 7 1 69241 7 2 36603 7 3 21018 7 5 75548 8 1 58867 8 2 67591 8 3 20517 8 4 70560 8 5 99861 8 6 50337 9 1 58971 9 2 89670 9 3 33820 9 6 71301 9 7 22784 9 8 81585 10 1 30341...
output:
596878
result:
ok 1 number(s): "596878"
Test #41:
score: 0
Accepted
time: 274ms
memory: 12680kb
input:
500 100000 2 1 82973 3 1 81605 3 2 24460 4 2 7174 4 3 71189 5 2 14318 5 3 93543 5 4 6666 6 1 96752 6 2 70646 6 3 78802 6 4 24772 7 1 46643 7 2 14722 7 4 59715 7 5 4164 7 6 26865 8 1 49632 8 3 25431 8 4 35548 8 5 39355 9 1 9500 9 2 8833 9 4 98694 9 5 17382 9 6 25765 9 7 57663 9 8 87954 10 1 10400 10 ...
output:
597720
result:
ok 1 number(s): "597720"
Test #42:
score: 0
Accepted
time: 254ms
memory: 12924kb
input:
500 100000 3 1 88166 3 2 90848 4 2 39502 4 3 20758 5 1 992 5 2 91705 5 3 48998 5 4 28802 6 2 55327 6 3 97752 6 4 84222 6 5 89360 7 2 77473 7 3 99265 7 4 90120 7 5 18797 7 6 55995 8 1 19341 8 2 96948 8 3 79262 8 4 27356 8 5 87472 8 6 27269 9 1 36217 9 2 85543 9 3 31979 9 5 17260 9 6 55898 9 7 88870 1...
output:
597376
result:
ok 1 number(s): "597376"
Test #43:
score: 0
Accepted
time: 265ms
memory: 12628kb
input:
500 100000 2 1 94433 3 1 99642 3 2 58028 4 1 41875 4 2 14838 5 1 85586 5 3 4382 6 1 64791 6 2 56127 7 3 28996 7 4 91496 7 5 8106 8 1 13058 8 2 90779 8 4 32394 8 5 37036 8 6 28899 8 7 97097 9 2 65400 9 3 14969 9 4 49346 9 5 1851 9 7 80237 9 8 31638 10 1 39455 10 2 19851 10 3 62220 10 4 52312 10 5 477...
output:
597581
result:
ok 1 number(s): "597581"
Test #44:
score: 0
Accepted
time: 269ms
memory: 11164kb
input:
500 100000 2 1 44213 3 2 17312 4 1 66019 4 2 76799 4 3 80729 5 1 42253 5 2 22005 5 3 69858 5 4 19123 6 2 24053 6 4 49343 6 5 39604 7 1 34335 7 4 73071 7 5 50622 7 6 12637 8 1 7373 8 4 33140 8 5 20244 8 6 14088 8 7 97180 9 1 15358 9 2 38353 9 3 49769 9 6 7823 9 7 70924 9 8 26728 10 2 29063 10 3 43139...
output:
597043
result:
ok 1 number(s): "597043"
Test #45:
score: 0
Accepted
time: 28ms
memory: 13340kb
input:
10000 100000 9311 4063 2 9311 4461 2 9311 8292 2 9311 8722 2 4063 4461 2 8292 8722 2 4398 9721 1 4898 3656 1 6898 3114 1 7472 3301 1 650 18 1 7632 3974 1 9421 3975 1 7428 1664 1 3865 6865 1 3390 7544 1 875 5541 1 5823 85 1 4073 5311 1 1467 9011 1 5132 1644 1 8744 4913 1 7915 6514 1 2101 4728 1 8866 ...
output:
12
result:
ok 1 number(s): "12"
Test #46:
score: 0
Accepted
time: 28ms
memory: 12088kb
input:
10000 100000 1686 197 2 1686 2173 2 1686 4903 2 1686 7553 2 197 2173 2 4903 7553 2 546 9778 1 1701 6044 1 8005 7622 1 8029 4105 1 2 5551 1 1594 8466 1 9683 2619 1 2560 5431 1 2069 2078 1 6238 3170 1 5176 3747 1 7200 7340 1 6643 1852 1 3857 2248 1 2513 1882 1 651 349 1 6396 2728 1 1901 6273 1 4580 43...
output:
12
result:
ok 1 number(s): "12"
Test #47:
score: 0
Accepted
time: 28ms
memory: 12728kb
input:
10000 100000 4060 1084 2 4060 3166 2 4060 6331 2 4060 9885 2 1084 3166 2 6331 9885 2 6695 9835 1 4856 4784 1 9112 8483 1 2233 1262 1 3002 1085 1 9204 2958 1 9944 1264 1 7691 9198 1 6625 940 1 5438 5148 1 9477 5600 1 8577 4594 1 5564 8393 1 6248 9133 1 9894 8472 1 6206 5784 1 4877 2591 1 1701 4170 1 ...
output:
12
result:
ok 1 number(s): "12"
Test #48:
score: 0
Accepted
time: 28ms
memory: 13148kb
input:
10000 100000 6435 1245 2 6435 2426 2 6435 2465 2 6435 7266 2 1245 2426 2 2465 7266 2 2844 9892 1 1659 3524 1 219 2991 1 6438 2066 1 6001 2970 1 3166 7449 1 206 9909 1 2822 2965 1 4829 6153 1 8286 7127 1 130 3806 1 9953 8201 1 8134 4934 1 8638 2370 1 7275 8710 1 8113 1220 1 9710 8805 1 1502 5715 1 23...
output:
12
result:
ok 1 number(s): "12"
Test #49:
score: 0
Accepted
time: 27ms
memory: 14100kb
input:
50000 99997 16790 23740 70239 23740 44810 42480 16790 44018 46689 16790 41568 26042 44810 7658 84821 23740 28819 48683 44018 21975 39423 44810 32228 16878 32228 5485 31525 28819 1226 12109 44810 24638 11451 32228 29724 40444 5485 10864 13818 7658 50 23190 7658 11214 75663 24638 24465 25344 23740 359...
output:
587278
result:
ok 1 number(s): "587278"
Test #50:
score: 0
Accepted
time: 22ms
memory: 14240kb
input:
50000 99997 15866 3324 90949 3324 20104 6091 3324 8531 45437 3324 18297 54820 3324 30502 2472 18297 44598 57640 30502 37177 31987 15866 11118 91233 30502 27439 22115 27439 27146 66902 3324 28223 9709 37177 17322 32310 37177 46806 22190 18297 34215 71811 17322 28904 42729 28223 39244 26590 28223 3210...
output:
586430
result:
ok 1 number(s): "586430"
Test #51:
score: 0
Accepted
time: 0ms
memory: 10852kb
input:
12 20 1 2 1 1 3 1 2 3 100 1 4 1 2 4 100 1 5 1 2 5 100 1 6 1 2 6 100 1 7 1 2 7 100 1 8 1 2 8 100 1 9 1 2 9 100 1 10 1 2 10 100 1 11 1 1 12 1 11 12 1
output:
105
result:
ok 1 number(s): "105"
Test #52:
score: 0
Accepted
time: 2ms
memory: 10504kb
input:
20 52 1 2 1 17 1 1 18 1 1 2 3 1 17 2 1 18 2 1 3 4 1 17 3 1 18 3 1 4 5 1 17 4 1 18 4 1 5 6 1 17 5 1 18 5 1 6 7 1 17 6 1 18 6 1 7 8 1 17 7 1 18 7 1 8 9 1 17 8 1 18 8 1 9 10 1 17 9 1 18 9 1 10 11 1 17 10 1 18 10 1 11 12 1 17 11 1 18 11 1 12 13 1 17 12 1 18 12 1 13 14 1 17 13 1 18 13 1 14 15 1 17 14 1 1...
output:
100302
result:
ok 1 number(s): "100302"