QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#831283 | #3302. Just Meeting | 通顶雪道 (Qiuyang Mang, Youran Sun, Qingshuo Guo)# | WA | 46ms | 9612kb | C++23 | 1.7kb | 2024-12-25 12:47:18 | 2024-12-25 12:47:20 |
Judging History
answer
#include <bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
int ch = 0, f = 0; x = 0;
for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
if(f) x = -x;
}
int main(){
int n, m; read(n), read(m);
vector<tuple<int, int, int> > e(m);
ll ans = 0;
for(int i = 0, x, y, z; i < m; i++){
read(x), read(y), read(z);
ans += z;
e[i] = {z, x, y};
}
sort(e.begin(), e.end()), reverse(e.begin(), e.end());
vector<int> fa(n + 1), sz(n + 1, 1);
for(int i = 1; i <= n; i++) fa[i] = i;
auto ask = [&](auto &dfs, int x) -> int { return x == fa[x] ? x : fa[x] = dfs(dfs, fa[x]); };
int last = 0;
for(int i = 0; i < m; i++){
if(i + 1 < m && get<0>(e[i + 1]) == get<0>(e[i])) continue;
for(int j = last; j <= i; j++){
auto [z, x, y] = e[j];
int p = ask(ask, x), q = ask(ask, y);
if(p == q) return puts("-1"), 0;
}
for(int j = last; j <= i; j++){
auto [z, x, y] = e[j];
int p = ask(ask, x), q = ask(ask, y);
ans -= z;
if(p == q) continue;
ans += 1ll * z * (sz[p] * sz[q]);
fa[p] = q, sz[q] += sz[p];
}
// cout << get<0>(e[i]) << " " << ans << endl;
last = i + 1;
}
for(int i = 2; i <= n; i++){
int p = ask(ask, i), q = ask(ask, i - 1);
if(p == q) continue;
ans += 1ll * sz[p] * sz[q];
fa[p] = q, sz[q] += sz[p];
}
cout << ans << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3604kb
input:
4 2 1 2 5 2 4 3
output:
14
result:
ok single line: '14'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
4 4 1 2 10 1 3 20 2 4 30 3 4 40
output:
-1
result:
ok single line: '-1'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
130 247 21 130 9826251 113 14 6000798 73 55 6258090 52 88 9123162 58 57 1750276 41 40 1630609 104 103 1750276 5 61 8486225 47 52 9243976 65 64 746976 130 87 6380955 26 25 2351803 71 70 189606 47 49 4015464 49 48 1630609 87 63 5089117 124 58 9959337 73 20 3496765 78 34 7789869 69 68 2994591 96 95 208...
output:
-1
result:
ok single line: '-1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
207 19 11 10 732134 5 4 444528 13 12 723858 17 16 64959 10 9 133983 9 8 661210 4 3 416495 15 14 740303 18 17 566802 19 18 692914 14 13 602221 16 15 144822 6 5 776502 7 6 570929 3 2 60173 20 19 486747 2 1 779525 8 7 606746 12 11 643657
output:
37712525
result:
ok single line: '37712525'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
186 269 142 141 5373289 66 65 4910100 110 109 7759528 94 93 2809357 50 49 1261298 2 1 5272448 146 145 602071 68 67 5272448 118 117 4022083 137 174 9510724 120 119 7808412 115 97 9942092 151 150 1261298 43 119 9650949 44 43 8315877 113 66 9166118 30 29 9014984 143 142 4621918 162 69 9459621 172 171 2...
output:
-1
result:
ok single line: '-1'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
291 20 4 3 2808901 10 9 573699 20 19 616858 8 7 1248928 9 8 483833 17 16 700554 6 5 455036 3 2 1779562 5 4 632027 11 10 1801411 15 14 661123 14 13 1224817 18 17 2104486 19 18 4193045 7 6 1540920 16 15 2216428 21 20 1670480 12 11 2433712 13 12 1935714 2 1 1079356
output:
140337842
result:
ok single line: '140337842'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
127 151 83 82 215103 52 51 128121 77 76 83069 87 40 2112995 10 9 158296 6 84 7414107 19 18 158296 126 125 180932 8 7 315382 4 3 158296 124 123 588493 61 60 154283 46 45 389333 52 27 1675967 90 89 552426 41 40 230260 41 36 8189327 48 47 257287 111 110 441447 35 34 158296 24 23 224466 37 36 6463039 16...
output:
-1
result:
ok single line: '-1'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
73 10 3 2 12608 11 10 82292 8 7 1581658 6 5 223002 4 3 131058 7 6 220313 10 9 1595495 5 4 722402 2 1 465004 9 8 942590
output:
13029938
result:
ok single line: '13029938'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
211 50 43 42 3354312 7 6 3216910 2 1 696369 25 24 1222424 51 50 2830101 35 34 1821861 33 32 1214397 39 38 4011606 28 27 1492176 46 45 1632220 5 4 1008492 17 16 2242236 18 17 2119279 21 20 1611326 47 46 1010910 23 22 4364287 19 18 364960 27 26 1487304 8 7 3361466 44 43 1691055 26 25 2407192 22 21 429...
output:
516852022
result:
ok single line: '516852022'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
200 265 21 61 4529486 55 54 3359530 139 138 2904011 142 141 2149180 102 101 1858872 88 87 3350392 198 197 1922055 100 99 1469856 37 36 3979928 45 44 3590367 81 80 952405 158 157 2527671 119 49 5353622 60 59 952405 185 184 3801765 11 10 1348271 72 195 4752711 40 39 4263919 187 199 9582700 18 12 89877...
output:
-1
result:
ok single line: '-1'
Test #11:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
194 192 86 85 3151812 67 66 3860526 101 100 3954555 15 14 2724016 157 156 2680597 31 30 1716299 129 128 845790 166 165 2257479 11 10 2302409 126 125 3609729 4 3 585471 96 95 611939 186 185 4710372 97 96 3562335 57 56 2024321 16 15 1388484 147 146 220786 63 62 4662185 161 160 4252836 109 108 4706726 ...
output:
3181762668
result:
ok single line: '3181762668'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
163 111 14 13 3589778 77 76 4652253 10 9 5010585 73 72 2789197 31 30 3817748 23 22 3151559 111 110 4135513 25 24 970105 75 74 1515231 50 49 279316 79 78 2027052 76 75 4660194 38 37 4168082 52 51 8380363 36 35 874055 32 31 4723623 5 4 3714440 83 82 2971393 88 87 7920753 61 60 7459923 72 71 7390683 18...
output:
3338550669
result:
ok single line: '3338550669'
Test #13:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
179 247 61 10 6435117 27 26 4239625 84 83 3647344 68 67 2543825 60 59 1966036 39 38 4236287 5 4 2360004 105 104 1801120 16 15 5411043 135 134 4791690 57 56 445378 110 109 3114742 143 81 7141724 32 31 766026 55 54 5113099 132 131 1371746 32 105 6580855 107 106 6017616 136 130 9398144 54 104 8968672 1...
output:
-1
result:
ok single line: '-1'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
54 30 13 12 4451759 27 26 4442161 12 11 2398964 9 8 4222140 16 15 2851764 14 13 1091330 23 22 4925509 15 14 4995104 19 18 4155182 2 1 397633 25 24 5352138 10 9 1815947 11 10 1671289 21 20 140242 3 2 2736736 4 3 5656461 22 21 5107000 31 30 4404262 5 4 4634846 7 6 952910 28 27 2313494 17 16 5633144 24...
output:
459486801
result:
ok single line: '459486801'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
255 227 227 226 4920207 27 26 5037533 116 115 5343557 170 169 1256435 108 107 871150 47 46 3123564 132 131 1484411 74 73 3818355 38 37 5063371 104 103 4719554 65 64 5249186 32 31 4095684 86 85 55312 43 42 1482335 113 112 2654992 212 211 630537 163 162 5385315 53 52 3520896 171 170 3905741 61 60 4107...
output:
3433971899
result:
ok single line: '3433971899'
Test #16:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
130 284 59 58 5026899 29 53 9798603 21 20 5026899 81 110 9388568 19 18 5026899 103 28 7491797 126 39 8479438 48 33 7654948 11 80 9444096 14 103 9529861 5 78 9197396 59 29 9031977 79 78 6982901 37 36 5026899 105 104 5026899 50 49 5026899 107 106 6982901 48 9 8233156 102 128 8941370 34 69 8983296 56 6...
output:
-1
result:
ok single line: '-1'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
85 118 38 37 1209805 8 32 7722935 2 1 2288425 30 29 2433690 80 18 6869924 61 60 764819 71 70 1347315 53 52 401541 78 36 2656698 26 67 3714951 78 77 2296467 82 81 1999286 73 72 965011 68 67 401541 52 51 401541 59 58 1305475 24 23 672477 63 62 1209805 47 46 1887669 70 69 1945153 60 59 672477 7 6 83521...
output:
-1
result:
ok single line: '-1'
Test #18:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
57 93 32 49 7850550 4 10 8264827 46 44 9617973 55 50 8450736 39 38 4401567 47 46 2582579 45 44 7085748 24 23 2582579 31 42 8610501 35 4 7090329 46 15 9473646 40 39 4808728 52 51 1800643 26 25 4401567 5 4 6129129 44 43 2199256 15 45 9679645 43 42 1800643 4 3 3658022 46 45 5133878 21 27 9079232 30 54 ...
output:
-1
result:
ok single line: '-1'
Test #19:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
176 175 50 49 6513742 144 143 6684921 167 166 7484424 60 59 6719840 89 88 4294989 111 110 3246132 108 107 477840 107 106 4068020 37 36 6921678 124 123 6250225 122 121 7341465 140 139 4612622 115 114 2519935 7 6 426614 59 58 2754419 116 115 855318 27 26 7490466 138 137 3571427 45 44 4257340 130 129 4...
output:
4589580169
result:
ok single line: '4589580169'
Test #20:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
105 176 16 15 4418819 2 42 9243328 42 13 7188238 94 21 7640939 6 90 8922062 26 25 2066736 20 19 4889528 33 32 3105227 72 18 8068211 103 40 8203087 103 44 7362663 76 73 6708024 5 4 617845 65 64 2063666 49 48 3107775 97 96 4723373 96 95 360424 40 39 4215407 36 71 6450278 31 2 6580901 21 20 3513161 19 ...
output:
-1
result:
ok single line: '-1'
Test #21:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
215 291 209 92 7288216 41 7 7598611 69 54 8843697 44 43 1985267 203 202 1902691 130 129 3202004 4 3 2232443 85 135 4087266 93 107 7656574 197 52 6366254 206 26 8742958 202 17 4625111 146 145 1259292 176 175 1157932 40 39 558337 178 177 1605391 213 125 9053510 191 190 3380859 153 210 4384068 213 166 ...
output:
-1
result:
ok single line: '-1'
Test #22:
score: 0
Accepted
time: 0ms
memory: 3836kb
input:
262 126 3 2 3098795 103 102 8564219 83 82 6036829 115 114 6536092 79 78 8106175 24 23 165638 77 76 3620360 124 123 1049822 30 29 7061028 68 67 7410671 78 77 6214815 31 30 5535880 113 112 431145 5 4 37979 125 124 798280 38 37 3593923 28 27 1139498 102 101 2951859 45 44 5217969 23 22 5262433 74 73 170...
output:
3786295028
result:
ok single line: '3786295028'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
81 126 43 42 4154398 54 10 9252918 75 6 8019509 2 73 8141826 60 66 8956596 53 52 1715638 68 67 4586396 6 5 2057336 39 27 8261441 52 81 8374317 58 32 8070467 7 6 7306819 39 38 1715638 70 69 1715638 77 76 1715638 69 68 4559684 22 21 3052432 48 47 3869704 49 48 6519881 13 12 6783759 72 71 3052432 75 74...
output:
-1
result:
ok single line: '-1'
Test #24:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
110 263 67 16 9480464 5 106 9511889 108 10 9842482 14 13 6490170 52 51 5342373 75 106 8056903 75 74 6893255 89 19 8479985 39 96 9546633 14 27 9239970 51 12 9814502 85 62 8741653 55 54 3439003 41 40 3439003 58 46 7596137 13 12 5342373 72 12 9887214 109 29 8179889 26 22 8605520 75 104 8776782 24 85 79...
output:
-1
result:
ok single line: '-1'
Test #25:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
136 134 135 134 2766651 110 109 5856753 95 94 4429621 67 66 4689372 97 96 5491403 113 112 466996 122 121 2977090 9 8 1203322 114 113 4874015 98 97 5012384 36 35 4509561 15 14 4117114 120 119 691244 80 79 408170 79 78 1116052 106 105 2968691 3 2 1530925 24 23 2620341 59 58 3793740 77 76 3875449 35 34...
output:
3301143919
result:
ok single line: '3301143919'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
266 48 29 28 586556 20 19 552538 13 12 85788 27 26 201902 26 25 449501 35 34 310529 41 40 147033 38 37 608042 25 24 244512 8 7 282783 34 33 122795 18 17 339531 40 39 333255 2 1 269756 44 43 134084 37 36 710342 31 30 48165 3 2 213422 6 5 593630 36 35 285921 4 3 380396 42 41 692517 16 15 36741 12 11 4...
output:
79688769
result:
ok single line: '79688769'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
138 135 31 30 6462399 53 52 6521505 36 35 7560087 27 26 6523700 128 127 4135279 26 25 2267516 48 47 5633730 131 130 3649191 118 117 6590437 41 40 5992010 71 70 7325138 122 121 4403757 105 104 812024 94 93 4203569 64 63 1072970 120 119 3220712 86 85 7579735 60 59 2870886 84 83 4076556 135 134 4430326...
output:
3644785203
result:
ok single line: '3644785203'
Test #28:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
189 6 6 5 1674399 3 2 1099952 4 3 3296551 5 4 3000448 7 6 3977167 2 1 21314
output:
28966397
result:
ok single line: '28966397'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
105 168 22 21 1381889 25 72 8746469 32 2 4821499 38 1 5696587 33 70 8089763 28 27 801183 50 49 1548994 24 23 1013932 90 70 6159074 103 57 6345002 58 86 5488325 52 90 3194225 41 40 275771 26 25 801183 85 84 984628 93 92 1530617 53 52 1108971 104 103 1381889 56 1 3124366 58 49 3067932 102 101 1108971 ...
output:
-1
result:
ok single line: '-1'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
31 206 3 7 8365285 1 6 9544049 1 25 8773283 13 31 8930943 31 30 8365285 11 27 8365285 26 31 8365285 20 16 8365285 30 26 8930943 10 4 9185480 26 4 8773283 11 24 8393277 30 4 8365285 28 21 8365285 27 10 8365285 30 10 8365285 21 30 8365285 18 28 8365285 29 19 8365285 11 16 8365285 22 25 8365285 8 15 83...
output:
-1
result:
ok single line: '-1'
Test #31:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
247 26 27 26 4727371 19 18 4488047 13 12 1748900 20 19 4283943 23 22 3014087 18 17 6572785 17 16 6089318 5 4 6207150 7 6 3635058 6 5 1481383 2 1 6646421 8 7 1404625 3 2 1138670 25 24 256171 10 9 2970148 15 14 7262305 9 8 6619556 26 25 4332493 16 15 5598491 4 3 3562409 12 11 1543514 21 20 7066703 24 ...
output:
629032100
result:
ok single line: '629032100'
Test #32:
score: 0
Accepted
time: 46ms
memory: 9612kb
input:
300000 300000 282382 282381 3148641 94384 94383 3148641 162159 162158 3148641 276002 276001 3148641 34111 34110 3148641 95098 95097 3148641 229144 229143 3148641 4779 4778 3148641 239092 239091 3148641 107595 107594 3148641 293286 293285 3148641 88743 88742 3148641 216793 216792 3148641 75237 75236 ...
output:
141688372703850000
result:
ok single line: '141688372703850000'
Test #33:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
19 171 15 3 9816118 12 5 9861342 14 6 9956040 18 1 9861342 18 12 9753180 14 2 9753180 17 16 9753180 15 10 9753180 10 17 9818685 15 1 9753180 2 18 9925601 16 19 9753180 19 9 9753180 5 4 9753180 5 9 9753180 2 17 9753180 19 11 9957361 3 17 9753180 14 19 9753180 10 3 9753180 18 7 9753180 4 10 9753180 13...
output:
-1
result:
ok single line: '-1'
Test #34:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
71 260 49 48 4271301 52 45 9642960 11 10 4271301 51 32 8660820 42 41 4271301 6 61 5584102 3 10 6951239 61 7 5874976 32 19 8822489 70 25 8968700 26 50 8598095 65 9 8239550 7 19 4271301 58 57 4271301 9 62 5753826 45 66 6936911 39 62 4271301 38 17 6699004 17 2 8059381 22 60 8059381 47 50 6699004 26 44 ...
output:
-1
result:
ok single line: '-1'
Test #35:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
220 291 152 82 9212597 178 216 9240671 150 193 9739465 28 27 4005563 114 113 3480168 120 119 7095139 203 202 4712304 137 178 8226641 28 8 9311560 101 73 9085577 113 53 9587072 118 165 8446112 217 216 2351662 73 72 2270426 183 182 987798 80 79 3115365 163 23 9771196 189 188 7461064 211 198 8276116 12...
output:
-1
result:
ok single line: '-1'
Test #36:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
277 275 97 96 6938568 141 140 7056667 35 34 7303819 231 230 2812757 33 32 2558964 216 215 5070482 69 68 3303492 252 251 6015023 133 132 7078117 244 243 6796276 110 109 7257527 239 238 6300388 72 71 1752238 263 262 1618411 3 2 253151 251 250 2215469 221 220 7333677 265 264 5309867 105 104 6190840 264...
output:
9872910272
result:
ok single line: '9872910272'
Test #37:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
237 206 25 24 814403 98 97 1267271 190 189 1087027 121 120 1111999 177 176 133628 113 112 528495 101 100 846868 145 144 629149 99 98 1157949 51 50 1165160 139 138 1093495 119 118 1021431 18 17 280275 206 205 507940 112 111 601932 140 139 844502 158 157 213756 118 117 807454 127 126 973298 169 168 97...
output:
1291941419
result:
ok single line: '1291941419'
Test #38:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
68 194 44 16 4046233 37 22 8908895 35 6 6725917 39 36 7313185 38 37 454242 30 7 1254084 15 66 4979463 62 47 1863510 26 59 7767655 23 68 7951566 2 63 6905333 55 40 6021290 36 35 654025 13 32 1254084 42 19 1863510 47 19 4979463 35 34 454242 22 51 3989702 19 11 5663114 58 47 5771212 38 25 3440636 7 10 ...
output:
-1
result:
ok single line: '-1'
Test #39:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
146 133 119 118 2260922 103 102 2304914 49 48 2525513 46 45 2307381 134 133 1541144 29 28 817135 78 77 2136580 115 114 1317894 16 15 2316262 65 64 2197694 77 76 2493110 126 125 1653019 38 37 297160 42 41 1556894 23 22 419107 118 117 1132552 59 58 2648239 2 1 1025113 94 93 1418529 18 17 1688020 99 98...
output:
1198579585
result:
ok single line: '1198579585'
Test #40:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
232 61 35 34 4585876 51 50 5315944 16 15 8392013 20 19 5396085 30 29 6679011 26 25 4478964 48 47 3405202 50 49 8348567 21 20 5419576 55 54 4022193 41 40 8060532 28 27 550945 61 60 926886 52 51 4593739 44 43 2470007 27 26 2262752 24 23 8696010 43 42 4210074 47 46 4134110 17 16 635371 58 57 6521167 37...
output:
2002371332
result:
ok single line: '2002371332'
Test #41:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
118 158 61 60 5197779 98 96 9456858 46 45 7947083 28 65 8348035 42 87 9300530 92 91 1961730 47 46 5521079 12 11 2996105 25 18 8698454 9 108 8816279 117 50 8194621 100 99 7068731 65 64 1582174 9 8 1871644 59 58 2846411 118 117 5505899 76 75 3650096 108 107 5164864 105 104 6686169 80 79 6753081 15 14 ...
output:
-1
result:
ok single line: '-1'
Test #42:
score: 0
Accepted
time: 0ms
memory: 3548kb
input:
48 26 11 10 6094936 27 26 6069788 24 23 2366074 2 1 5506983 6 5 3046255 13 12 7447933 16 15 6467342 15 14 6471999 14 13 4346088 26 25 1876347 4 3 7712295 5 4 1215720 22 21 558151 20 19 436824 8 7 2957197 23 22 8419127 25 24 7628584 10 9 5928858 9 8 6383759 12 11 3776655 19 18 2273266 21 20 8361595 7...
output:
602295912
result:
ok single line: '602295912'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
122 275 46 61 9126278 91 117 9300888 41 1 9734521 42 41 5110507 47 46 3952858 40 77 6658235 114 113 5110507 82 16 7777112 34 98 9307346 60 100 8873674 21 29 9681918 98 7 7967958 73 72 2886826 56 55 2434727 67 66 2434727 4 3 3952858 3 56 9810259 84 65 7118775 75 122 7876960 111 119 8039871 61 25 6591...
output:
-1
result:
ok single line: '-1'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
244 274 166 165 3033204 210 216 9960886 44 43 1199636 198 197 9700153 107 106 2682994 190 189 6280658 167 166 8038180 18 17 6708330 219 218 9864593 31 77 9923111 235 234 9602288 92 91 9253029 26 25 4743789 72 71 2248582 71 70 613223 123 122 7997811 89 88 4180436 126 125 7571041 240 239 9044100 80 79...
output:
-1
result:
ok single line: '-1'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
31 259 5 24 9772506 29 3 9813019 2 12 9928148 11 29 9397003 5 8 9397003 21 27 9397003 13 24 9397003 15 11 9397003 20 27 9818216 30 15 9728574 14 4 9915255 24 31 9397003 13 18 9397003 26 25 9397003 31 3 9397003 25 7 9397003 29 7 9933162 10 20 9397003 27 6 9397003 5 25 9397003 17 20 9397003 24 28 9397...
output:
-1
result:
ok single line: '-1'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
174 221 162 29 5004128 50 12 5719922 38 158 8646889 28 27 195503 108 107 145283 153 152 514508 163 162 246086 6 5 616794 120 136 6022605 112 148 3939591 7 52 8308794 89 88 670850 38 37 414852 4 3 229181 160 159 445255 138 137 86037 171 57 8695963 66 65 562303 54 53 640341 129 128 682755 125 124 4973...
output:
-1
result:
ok single line: '-1'
Test #47:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
189 238 14 13 89570 49 110 7669537 82 8 1372009 67 135 2653812 55 54 37961 82 81 304964 174 173 458843 112 111 360505 96 74 3693720 155 21 3995114 34 162 1495142 117 116 533356 173 172 207329 101 100 23421 8 7 345834 115 114 450555 5 4 184192 81 80 431483 163 162 517563 120 119 522557 62 61 386581 8...
output:
-1
result:
ok single line: '-1'
Test #48:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
199 70 56 55 4563935 57 56 4408896 42 41 2556398 62 61 3041123 15 14 4234401 16 15 895408 45 44 944588 49 48 4869480 68 67 3167411 19 18 3267399 2 1 2889646 47 46 1677744 29 28 701853 53 52 3242918 48 47 91752 67 66 5218012 70 69 2467740 24 23 404152 36 35 1243579 59 58 1462263 44 43 3737419 66 65 5...
output:
955086248
result:
ok single line: '955086248'
Test #49:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
154 84 49 48 156418 66 65 3796412 13 12 2538657 25 24 2867822 78 77 3670392 16 15 713127 56 55 371925 69 68 4056395 72 71 3082697 51 50 3177623 74 73 2591065 63 62 2125922 21 20 1291431 57 56 3167611 46 45 1059802 61 60 344045 26 25 2498518 6 5 193860 3 2 1582471 30 29 1664898 48 47 3485787 19 18 44...
output:
1028665678
result:
ok single line: '1028665678'
Test #50:
score: 0
Accepted
time: 0ms
memory: 3868kb
input:
259 185 38 37 5624722 167 166 5669117 129 128 6128113 102 101 387442 172 171 4187114 3 2 3069314 142 141 900793 94 93 4110884 63 62 5759266 48 47 5380759 185 184 6054658 128 127 4401462 50 49 2210888 107 106 848154 183 182 2437138 93 92 1469001 15 14 6143035 14 13 3682739 53 52 4170126 59 58 4457175...
output:
5323438960
result:
ok single line: '5323438960'
Test #51:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
272 25 8 7 3643478 15 14 440405 13 12 4501332 25 24 778462 17 16 3145162 23 22 4912993 26 25 2649196 7 6 4262242 14 13 2070124 21 20 269422 20 19 4146699 4 3 2377427 11 10 4710254 16 15 4835829 19 18 4474653 18 17 2218117 24 23 4643575 9 8 2362168 5 4 4726108 22 21 3928959 2 1 2931928 10 9 4875844 1...
output:
277495131
result:
ok single line: '277495131'
Test #52:
score: 0
Accepted
time: 0ms
memory: 3544kb
input:
293 73 48 47 1989233 5 4 2072987 25 24 2890328 59 58 2152162 74 73 233741 9 8 53347 23 22 1424930 18 17 83287 2 1 2251198 57 56 1560792 3 2 2783160 8 7 551896 37 36 779396 26 25 265364 7 6 1237694 72 71 156326 67 66 2949591 50 49 1795953 45 44 177671 22 21 592517 4 3 2540732 53 52 3144559 58 57 2063...
output:
499129561
result:
ok single line: '499129561'
Test #53:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
267 47 24 23 4964796 38 37 5493643 26 25 7954937 16 15 5500388 13 12 6973878 28 27 4543091 22 21 1355389 6 5 7760359 20 19 5876974 35 34 2833672 2 1 7511811 41 40 6292036 18 17 8147527 45 44 4981738 29 28 242501 27 26 165100 14 13 8130923 46 45 3386595 32 31 2871730 19 18 7273043 31 30 6808934 39 38...
output:
935844158
result:
ok single line: '935844158'
Test #54:
score: 0
Accepted
time: 0ms
memory: 3488kb
input:
7 21 2 4 8128465 5 7 8128465 2 6 8128465 1 6 9196680 3 5 8128465 7 2 9997706 4 3 8128465 4 6 8128465 6 5 8128465 3 2 8128465 7 4 8128465 5 4 8128465 1 4 8608975 5 1 9014397 7 3 8128465 7 6 8128465 6 3 8128465 2 1 8128465 1 7 8666935 1 3 8128465 5 2 8128465
output:
-1
result:
ok single line: '-1'
Test #55:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
249 296 173 172 2497562 145 94 9369342 237 236 1396767 199 106 8519505 76 75 2199969 48 47 5290797 125 124 6711450 239 238 5682440 188 104 8671648 200 234 8782982 109 155 8323409 230 229 7746630 189 188 4136349 119 118 1973527 215 214 864119 149 148 827430 21 20 3625617 28 27 6426457 129 128 8848782...
output:
-1
result:
ok single line: '-1'
Test #56:
score: 0
Accepted
time: 0ms
memory: 3540kb
input:
3 3 2 1 262803 3 2 262803 3 1 4975191
output:
5500797
result:
ok single line: '5500797'
Test #57:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
107 22 3 2 3552054 4 3 2835268 17 16 1033917 10 9 2606462 7 6 1228196 9 8 4968811 13 12 4546115 14 13 4699685 18 17 2238893 16 15 4160167 20 19 5772480 2 1 1880792 11 10 1036651 15 14 5817123 6 5 1175941 12 11 6345210 21 20 5497991 23 22 2690861 22 21 4155972 5 4 2013964 19 18 974840 8 7 5984622
output:
375743954
result:
ok single line: '375743954'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
277 172 30 29 1937111 88 87 3249721 31 30 2600487 4 3 2746319 53 52 3079229 167 166 1251238 82 81 1989565 87 86 1439497 37 36 2816404 110 109 2899251 48 47 2677935 2 1 2398306 79 78 383435 160 159 1199545 132 131 1400587 52 51 1983261 103 102 1484106 97 96 1873664 68 67 2268799 151 150 2279798 159 1...
output:
3188883707
result:
ok single line: '3188883707'
Test #59:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
93 288 73 72 2803072 71 85 9297555 60 59 2803072 78 11 8612616 15 14 2803072 42 37 5256388 62 55 7027254 55 70 5921357 93 8 8709590 6 35 8776860 10 54 8527069 86 44 7901325 16 32 4008652 69 68 2803072 49 48 2803072 62 61 2803072 50 91 4008652 52 38 6646928 85 63 7750921 52 32 7901325 8 72 6054660 30...
output:
-1
result:
ok single line: '-1'
Test #60:
score: 0
Accepted
time: 0ms
memory: 3500kb
input:
138 200 26 25 4421128 75 65 8598446 129 119 6318759 97 41 6875182 41 40 235838 60 59 2961569 10 9 4542361 134 133 3447571 134 21 6961785 27 45 7181920 55 9 6613759 86 69 5634955 56 55 1415205 65 64 2654052 29 28 3131819 129 128 4508480 32 31 802354 75 74 4324010 73 64 5512416 6 30 5575482 110 109 37...
output:
-1
result:
ok single line: '-1'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2763 380 84 83 1617950 201 200 1548948 114 113 5576064 2 1 7322033 297 296 2519833 235 234 5557982 93 92 3732329 3 2 5795965 272 271 728568 171 170 779924 87 86 3530890 359 358 7506258 81 80 2908845 343 342 1793703 92 91 6667855 329 328 3455919 228 227 2544699 103 102 3593779 353 352 5516512 197 196...
output:
12924551612
result:
ok single line: '12924551612'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2340 1272 797 796 1332821 36 35 566293 568 567 57084 894 893 625204 1073 1072 563555 915 914 1570692 794 793 133054 906 905 796202 363 362 1254210 519 518 1257968 474 473 1454388 232 231 389621 623 622 951175 1055 1054 1351619 267 266 1644700 575 574 1152161 533 532 91303 467 466 363586 91 90 456875...
output:
11859658917
result:
ok single line: '11859658917'
Test #63:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
2787 760 599 598 3066034 268 267 1133579 102 101 3103602 127 126 1949707 37 36 2968700 630 629 242019 34 33 991758 228 227 3735164 731 730 2168291 647 646 1226787 597 596 2397159 335 334 3057570 745 744 4445401 338 337 3854304 137 136 2100175 63 62 2491626 121 120 2722726 448 447 2975411 16 15 43437...
output:
16773969285
result:
ok single line: '16773969285'
Test #64:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
1555 1016 769 768 4478453 25 24 2691842 683 682 4503144 532 531 3407351 530 529 4382175 572 571 1827149 133 132 33149 147 146 153974 903 902 3623210 48 47 2754414 424 423 3803118 211 210 4470989 285 284 5991693 756 755 5369087 791 790 1013458 724 723 3882980 256 255 4132566 91 90 4391026 706 705 589...
output:
24711578134
result:
ok single line: '24711578134'
Test #65:
score: 0
Accepted
time: 1ms
memory: 3684kb
input:
279 1421 238 237 8500646 18 88 8500646 95 121 9783734 34 33 8500646 180 216 9487335 261 94 9819923 175 121 9210801 180 270 8808626 184 268 9475286 246 195 9444112 153 237 9210801 51 29 9656279 170 160 9876495 186 185 8500646 145 42 8500646 274 273 8500646 263 262 8500646 80 194 9957756 26 76 9326089...
output:
-1
result:
ok single line: '-1'
Test #66:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
1243 250 158 157 6398057 183 182 6967738 10 9 898630 163 162 6660986 44 43 309074 58 57 4458413 174 173 2351894 97 96 2071102 167 166 2779699 157 156 5153731 229 228 5763225 51 50 4202443 115 114 6217417 63 62 2943546 182 181 578987 40 39 2934609 165 164 3192902 148 147 6878253 137 136 5721190 179 1...
output:
8328051226
result:
ok single line: '8328051226'
Test #67:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1406 63 41 40 411179 44 43 38305 5 4 90722 43 42 654436 34 33 302223 20 19 262345 24 23 198314 4 3 634823 53 52 83126 28 27 710701 13 12 506790 25 24 625803 55 54 543082 17 16 763792 48 47 617170 8 7 537929 16 15 510882 57 56 523119 11 10 570767 15 14 651034 58 57 757764 14 13 562555 3 2 744804 46 4...
output:
129531007
result:
ok single line: '129531007'
Test #68:
score: 0
Accepted
time: 1ms
memory: 3572kb
input:
450 1822 369 368 5911101 34 4 6544343 200 249 6718822 172 204 7958540 176 175 5911101 101 100 5911101 112 89 7414041 335 50 7110094 339 395 9131382 244 39 8949498 57 348 8269637 82 57 6718822 382 282 9060083 226 70 7537514 50 317 8348827 199 232 6544343 320 174 9208229 103 397 7835766 77 10 6978265 ...
output:
-1
result:
ok single line: '-1'
Test #69:
score: 0
Accepted
time: 1ms
memory: 3888kb
input:
214 2567 110 163 9809243 31 109 9987174 183 182 9809243 73 107 9872342 163 162 9809243 103 127 9809243 90 116 9809243 214 213 9809243 93 136 9932410 79 64 9985540 43 52 9809243 122 172 9872342 15 14 9809243 151 112 9908346 178 171 9809243 77 124 9809243 84 203 9809243 59 23 9872342 140 1 9809243 206...
output:
-1
result:
ok single line: '-1'
Test #70:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1812 223 38 37 376625 28 27 1082677 179 178 795186 72 71 903 208 207 321550 165 164 1147173 153 152 139463 154 153 1314202 44 43 1084831 173 172 1018729 160 159 1185353 118 117 393086 207 206 1245801 155 154 720921 34 33 613792 4 3 975255 210 209 254081 120 119 497946 17 16 214383 61 60 401850 149 1...
output:
1483854148
result:
ok single line: '1483854148'
Test #71:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
1891 271 34 33 6643942 58 57 8807303 20 19 9001309 51 50 406496 191 190 6692744 72 71 3561249 52 51 9377752 70 69 5949609 236 235 8211360 227 226 3432952 268 267 6895290 43 42 1717030 194 193 5421023 84 83 4757765 202 201 8205448 92 91 2580686 83 82 4850470 54 53 4368002 8 7 3130573 57 56 9252272 66...
output:
9560771912
result:
ok single line: '9560771912'
Test #72:
score: 0
Accepted
time: 0ms
memory: 3492kb
input:
88 412 38 37 9726935 43 42 9549801 64 16 9861129 21 17 9549801 65 23 9862475 77 32 9549801 46 51 9991422 13 12 9549801 80 35 9990445 51 63 9549801 68 15 9866962 81 36 9549801 57 9 9848582 52 58 9549801 61 49 9857794 33 45 9852739 39 60 9726935 4 8 9855572 32 44 9549801 87 83 9908744 39 20 9633963 14...
output:
-1
result:
ok single line: '-1'
Test #73:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1058 984 839 838 1968412 307 306 1068954 589 588 460361 732 731 1608622 92 91 440109 52 51 370638 733 732 2266205 887 886 1240028 735 734 2265344 329 328 495953 770 769 155897 423 422 1780330 646 645 1093662 95 94 1493860 147 146 997217 750 749 2094076 354 353 1286082 238 237 451113 705 704 1366962 ...
output:
14062169804
result:
ok single line: '14062169804'
Test #74:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
1387 579 572 571 1632048 449 448 1992638 195 194 2422232 244 243 872733 478 477 1482353 153 152 2393056 412 411 2031927 132 131 421094 93 92 343127 267 266 813503 510 509 2595416 291 290 3277004 135 134 2590959 495 494 3077859 570 569 2908548 209 208 1652896 178 177 310470 118 117 866795 251 250 293...
output:
12002252657
result:
ok single line: '12002252657'
Test #75:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
1999 2620 674 1868 415753 1343 1342 118364 1814 1813 244939 1040 1039 220444 1177 1176 119711 600 599 85401 516 515 61802 1927 1329 7049285 885 884 273304 1197 801 5779790 1575 1574 92048 759 496 3466266 1921 1920 216744 842 841 320209 1398 1347 3830840 1692 107 6664653 1376 1375 297829 1107 1106 22...
output:
-1
result:
ok single line: '-1'
Test #76:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
471 2977 188 333 9995255 71 70 9189464 450 354 9540911 319 27 9882349 35 66 9896099 427 13 9189464 27 320 9783414 420 471 9277688 217 422 9189464 362 427 9689410 263 222 9189464 143 73 9189464 392 179 9646851 281 394 9555026 323 228 9466852 430 365 9189464 254 43 9512805 20 331 9915048 97 313 918946...
output:
-1
result:
ok single line: '-1'
Test #77:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
2761 2751 144 143 1214160 1105 1104 7018902 832 831 1049490 1967 1966 1451759 795 794 3456473 2561 2560 60333 1424 1423 5418540 1587 1586 7211295 50 49 3024249 445 444 5226048 2134 2133 1121860 1047 1046 1052570 2424 2423 5492803 1099 1098 4452858 245 244 2072165 2722 2721 7011488 1524 1523 222528 1...
output:
125578688111
result:
ok single line: '125578688111'
Test #78:
score: 0
Accepted
time: 0ms
memory: 3576kb
input:
2130 931 279 278 1030449 493 492 5525371 771 770 2002990 828 827 1331547 374 373 2731716 579 578 91107 13 12 3930952 207 206 1185440 139 138 911623 46 45 2130052 30 29 2430716 409 408 5380538 841 840 5596525 846 845 4987668 295 294 1293549 444 443 4950243 309 308 5276509 73 72 4981127 657 656 547223...
output:
39587038352
result:
ok single line: '39587038352'
Test #79:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
2153 357 177 176 670252 241 240 497417 283 282 688051 225 224 431594 298 297 66652 5 4 532176 268 267 310303 254 253 736273 312 311 474980 198 197 677635 84 83 522330 79 78 455703 331 330 521694 99 98 296026 260 259 247887 271 270 280148 109 108 421033 323 322 292266 62 61 475980 248 247 724583 21 2...
output:
1115948802
result:
ok single line: '1115948802'
Test #80:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
2636 1589 1139 1138 224989 503 502 1902041 1560 1559 1745072 244 243 3377424 1203 1202 2539160 1196 1195 1677401 1353 1352 4940553 951 950 400693 1251 1250 3149214 1378 1377 3797711 1425 1424 3945191 1491 1490 5845401 440 439 5967458 236 235 1211148 688 687 3328577 733 732 149844 1294 1293 5781146 1...
output:
70094027010
result:
ok single line: '70094027010'
Test #81:
score: 0
Accepted
time: 13ms
memory: 6380kb
input:
286978 65345 43640 43639 5370967 30771 30770 5651386 22319 22318 2156812 45736 45735 4209840 57257 57256 1749458 60998 60997 5664990 59122 59121 7055103 63687 63686 322742 3120 3119 2695663 16422 16421 873859 27586 27585 4128582 51963 51962 152701 43611 43610 6566950 11236 11235 297356 817 816 64901...
output:
4287498932039
result:
ok single line: '4287498932039'
Test #82:
score: 0
Accepted
time: 19ms
memory: 4924kb
input:
6621 143570 6016 6015 8400670 1120 4905 8400670 1533 2586 9338923 2763 4149 8400670 5141 6020 8400670 6557 6067 9526775 5996 3559 8400670 3229 2358 8400670 2017 2557 8990295 5084 4819 9177647 2517 5320 9215556 3283 888 8400670 1420 5996 9327388 3299 4330 8400670 532 6237 8400670 3726 89 8400670 1629...
output:
-1
result:
ok single line: '-1'
Test #83:
score: 0
Accepted
time: 29ms
memory: 6644kb
input:
122958 200141 70742 70741 1469302 90252 90251 990582 6595 6594 3221626 82259 82258 1404591 25143 79632 3893228 47682 94905 9618269 64868 120612 5915767 1561 103423 9070714 26115 26114 358794 25712 25711 3098223 112408 112407 186524 60545 60544 772813 31074 109584 8227192 103607 103606 3199629 112770...
output:
-1
result:
ok single line: '-1'
Test #84:
score: -100
Wrong Answer
time: 35ms
memory: 7928kb
input:
295922 231287 202340 202339 3965444 144095 144094 3927193 114465 114464 3152292 179593 179592 3816365 164449 164448 3732512 66822 66821 2921701 104172 104171 1424289 63234 63233 1387419 206528 206527 3679089 116662 116661 2458651 187590 187589 3162005 21506 21505 1182797 101446 101445 3582646 742 74...
output:
9994324380740
result:
wrong answer 1st lines differ - expected: '11377303850052', found: '9994324380740'