QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875450 | #2714. Mountains and Valleys | hhoppitree | 2 | 1379ms | 133876kb | C++17 | 4.4kb | 2025-01-29 20:04:14 | 2025-01-29 20:04:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 5e5 + 5;
int n, S, T;
vector<int> G[N];
int dep[N];
namespace tree_lca {
int dfn[N], dfn_c, pos[20][N];
int get(int x, int y) {
return dfn[x] < dfn[y] ? x : y;
}
void init() {
auto dfs = [&](auto &&self, int x, int fa = 0) -> void {
dfn[x] = ++dfn_c;
pos[0][dfn_c] = fa;
for (auto v : G[x]) {
if (v != fa) self(self, v, x);
}
};
dfs(dfs, S);
for (int i = 1; (1 << i) <= n; ++i) {
for (int j = 1; j + (1 << i) - 1 <= n; ++j) {
pos[i][j] = get(pos[i - 1][j], pos[i - 1][j + (1 << (i - 1))]);
}
}
}
int LCA(int x, int y) {
if (x == y) return x;
x = dfn[x], y = dfn[y];
if (x > y) swap(x, y);
int k = 31 - __builtin_clz(y - x++);
return get(pos[k][x], pos[k][y - (1 << k) + 1]);
}
}
int LCA(int x, int y) {
return tree_lca::LCA(x, y);
}
vector<int> chain;
int pre[N], nxt[N];
struct Info {
int f[N], g[N], h[N], F[N];
void init(int rt) {
auto dfs1 = [&](auto &&self, int x, int fa = 0) -> void {
for (auto v : G[x]) {
if (v == fa) continue;
self(self, v, x);
if (v != pre[x] && v != nxt[x]) {
f[x] = max(f[x], f[v] + 1);
}
}
};
dfs1(dfs1, rt);
auto dfs2 = [&](auto &&self, int x, int fa = 0, int D = 1) -> void {
h[x] = f[x] - D + 1;
for (auto v : G[x]) {
if (v != fa && (v == pre[x] || v == nxt[x])) {
g[v] = max(g[x], D + f[v]);
self(self, v, x, D + 1);
h[x] = max(h[x], h[v]);
}
}
};
dfs2(dfs2, rt);
auto dfs3 = [&](auto &&self, int x, int fa = 0, int D = 0, int ty = 0) -> void {
// F[x] = D + f[x];
for (auto v : G[x]) {
if (v == fa) continue;
int nty = (ty || (v != pre[x] && v != nxt[x]));
self(self, v, x, D + (nty ? -1 : 1), nty);
}
};
dfs3(dfs3, rt);
}
} p[2];
void init() {
auto getFar = [&](int st) {
int mxDep = 0, wh = 0;
dep[st] = 1;
auto dfsFar = [&](auto &&self, int x, int fa = 0) -> void {
for (auto v : G[x]) {
if (v != fa) dep[v] = dep[x] + 1, self(self, v, x);
}
if (dep[x] > mxDep) {
mxDep = dep[x], wh = x;
}
};
dfsFar(dfsFar, st);
return wh;
};
S = getFar(1), T = getFar(S);
auto dfsChain = [&](auto &&self, int x) {
chain.push_back(x);
if (x == S) return;
for (auto v : G[x]) {
if (dep[v] < dep[x]) self(self, v);
}
};
dfsChain(dfsChain, T), reverse(chain.begin(), chain.end());
for (int i = 1; i < (int)chain.size(); ++i) {
pre[chain[i]] = chain[i - 1];
nxt[chain[i - 1]] = chain[i];
}
tree_lca::init();
p[0].init(S), p[1].init(T);
}
int dis(int x, int y) {
return dep[x] + dep[y] - 2 * dep[LCA(x, y)];
}
int query(int x, int y) {
int a = LCA(x, T), b = LCA(y, T);
if (dep[a] > dep[b]) swap(x, y), swap(a, b);
if (dep[a] == dep[b] || dep[a] + 1 == dep[b]) {
return dep[T] - dep[S];
}
int res = dep[T] - dep[S] - (dep[b] - dep[a] - 1) * 2;
if (a != S) res = max(res, p[0].g[pre[a]]);
if (b != T) res = max(res, p[1].g[nxt[b]]);
res = max(res, p[0].h[nxt[a]] + 2 * dep[a]);
res = max(res, p[1].h[pre[b]] + 2 * (dep[S] + dep[T] - dep[b]));
res = max({res, p[0].F[a], p[1].F[b]});
return res;
}
signed main() {
int m; scanf("%d%d", &n, &m);
vector< array<int, 3> > apd;
for (int i = 1, x, y, w; i <= m; ++i) {
scanf("%d%d%d", &x, &y, &w), ++x, ++y;
if (w == 1) G[x].push_back(y), G[y].push_back(x);
else apd.push_back({x, y, w});
}
init();
int res = 2 * (n - 1) - dis(S, T);
for (auto [x, y, w] : apd) {
if (w * 2 <= n) {
int D = dis(x, y);
if (D > w) {
res = min(res, 2 * (n - 1) - D + w - query(x, y));
}
}
}
printf("%d\n", res);
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 1
Accepted
time: 1ms
memory: 31840kb
input:
4 3 0 1 1 0 2 1 0 3 1
output:
4
result:
ok single line: '4'
Test #2:
score: 1
Accepted
time: 1ms
memory: 32624kb
input:
6 10 0 2 1 1 0 1 3 5 1 3 4 1 2 4 1 1 5 2 3 0 2 1 3 2 0 5 3 5 2 2
output:
5
result:
ok single line: '5'
Test #3:
score: 1
Accepted
time: 1ms
memory: 32448kb
input:
6 10 3 0 2 5 4 2 4 0 1 4 1 2 0 2 1 2 5 1 3 1 1 4 3 3 3 2 2 5 1 1
output:
5
result:
ok single line: '5'
Test #4:
score: 1
Accepted
time: 1ms
memory: 29792kb
input:
6 10 0 1 1 5 0 1 4 1 1 5 2 3 1 3 1 2 0 2 2 3 1 4 5 2 2 4 2 5 3 2
output:
6
result:
ok single line: '6'
Test #5:
score: 1
Accepted
time: 1ms
memory: 33880kb
input:
6 10 0 5 2 1 5 2 2 1 1 1 0 1 3 4 3 4 1 1 3 5 2 5 2 1 3 1 1 5 4 2
output:
7
result:
ok single line: '7'
Test #6:
score: 1
Accepted
time: 2ms
memory: 29888kb
input:
6 10 1 2 1 2 3 2 3 1 1 4 5 6 5 3 4 1 5 1 0 4 3 0 3 3 0 1 1 1 4 1
output:
8
result:
ok single line: '8'
Test #7:
score: 1
Accepted
time: 1ms
memory: 33048kb
input:
6 10 2 5 3 2 4 2 2 0 2 4 3 1 4 0 3 2 1 3 3 5 1 2 3 1 1 3 1 0 3 1
output:
8
result:
ok single line: '8'
Test #8:
score: 1
Accepted
time: 1ms
memory: 33776kb
input:
6 10 5 1 2 0 1 2 0 5 1 2 4 1 3 1 1 2 3 2 3 0 2 4 1 1 5 2 1 5 3 2
output:
5
result:
ok single line: '5'
Test #9:
score: 1
Accepted
time: 0ms
memory: 32428kb
input:
6 10 2 1 2 0 2 1 4 2 1 3 1 1 5 0 1 1 5 1 3 4 3 3 0 2 2 3 2 1 4 2
output:
5
result:
ok single line: '5'
Test #10:
score: 1
Accepted
time: 2ms
memory: 32364kb
input:
6 10 2 3 1 0 3 2 2 1 2 4 5 2 4 1 1 2 5 1 0 5 1 0 4 2 3 4 1 0 1 3
output:
5
result:
ok single line: '5'
Test #11:
score: 1
Accepted
time: 3ms
memory: 32364kb
input:
6 10 0 1 2 1 4 2 1 5 2 0 4 1 5 0 1 5 3 2 2 3 1 0 2 1 2 1 1 5 4 5
output:
6
result:
ok single line: '6'
Test #12:
score: 1
Accepted
time: 1ms
memory: 32512kb
input:
6 10 2 0 2 5 1 1 0 3 2 2 3 2 5 0 5 3 4 1 5 2 1 5 3 2 0 1 1 4 5 1
output:
6
result:
ok single line: '6'
Test #13:
score: 1
Accepted
time: 0ms
memory: 33220kb
input:
6 10 4 2 1 1 5 1 5 0 1 0 3 2 3 5 2 0 4 2 2 5 1 3 2 1 2 0 6 4 3 5
output:
6
result:
ok single line: '6'
Test #14:
score: 0
Wrong Answer
time: 2ms
memory: 33620kb
input:
6 6 1 5 1 5 0 1 3 1 2 3 2 1 4 2 1 2 5 1
output:
7
result:
wrong answer 1st lines differ - expected: '6', found: '7'
Subtask #2:
score: 0
Wrong Answer
Test #16:
score: 2
Accepted
time: 1ms
memory: 34408kb
input:
9 10 0 1 1 0 2 1 0 3 1 1 4 1 2 5 1 2 6 1 3 7 1 3 8 1 2 4 5 6 7 3
output:
11
result:
ok single line: '11'
Test #17:
score: 0
Wrong Answer
time: 2ms
memory: 32144kb
input:
9 9 0 1 1 1 2 1 2 3 1 3 4 1 2 5 1 5 6 1 2 7 1 7 8 1 4 6 3
output:
12
result:
wrong answer 1st lines differ - expected: '11', found: '12'
Subtask #3:
score: 2
Accepted
Test #35:
score: 2
Accepted
time: 4ms
memory: 52856kb
input:
5000 10000 1867 4363 2515 262 989 2506 22 808 1 3969 1940 1 301 4586 2912 2193 1408 1 2656 3426 2589 643 4376 2570 4986 4031 1 2149 538 2636 1662 183 2518 3111 3252 2885 3710 216 2679 4540 11 1 4690 3663 1 3549 4010 2666 2480 3321 1 216 15 2530 1228 3212 2965 1923 1417 2724 3832 1842 2649 3937 1191 ...
output:
4999
result:
ok single line: '4999'
Test #36:
score: 2
Accepted
time: 5ms
memory: 51816kb
input:
4999 10000 1811 2026 2694 3479 3673 2663 1418 2998 2511 1533 746 1 3141 2435 1 8 3832 1 3350 4951 1 3866 1685 1 3174 803 1 4859 2198 3111 2532 3104 1 360 2983 3434 4810 661 1 3196 3277 1 3766 4511 1 4665 38 1 3829 3722 1 3669 3100 1 3779 3560 3109 2532 257 1 4494 1302 3212 2300 4182 1 1122 2796 1 41...
output:
4998
result:
ok single line: '4998'
Test #37:
score: 2
Accepted
time: 2ms
memory: 50796kb
input:
4999 10000 4535 296 2529 4754 1564 2631 4255 1701 1 4776 1038 1 4180 3807 2633 2924 1082 2508 372 51 2899 2041 2754 2524 1976 3391 2563 4103 4955 2566 419 840 1 355 1999 2504 3726 2488 2587 728 836 1 355 97 2501 2852 1901 2503 4034 2911 1 2202 2453 1 3239 327 2778 436 686 1 2370 1022 2514 3866 3929 ...
output:
6664
result:
ok single line: '6664'
Test #38:
score: 2
Accepted
time: 3ms
memory: 54440kb
input:
4998 10000 4160 4537 1 3358 2521 1 2897 4536 1 2004 3684 1 543 139 3825 641 1841 3630 4934 3527 3118 144 2651 1 2185 3663 1 3382 2931 1 1095 3978 1 3934 1384 3439 3777 1089 2697 4732 591 3854 717 4222 3394 88 1043 1 1606 1970 1 2491 2131 2813 4924 1126 2662 1001 440 3886 369 1061 1 2667 2847 1 4975 ...
output:
7495
result:
ok single line: '7495'
Test #39:
score: 2
Accepted
time: 3ms
memory: 54268kb
input:
4998 10000 2997 3161 1 3664 4692 2648 3671 4617 1 1427 3471 1 3455 3660 2810 3979 2418 1 4606 471 1 1809 3050 2728 1531 3037 1 2254 4415 1 2445 1898 1 2772 3275 1 2729 204 4604 1485 1625 4570 971 3747 4039 2616 1632 3080 4925 3300 1 4045 4637 4115 456 4869 1 2662 4208 1 745 195 1 2497 1663 1 669 651...
output:
7994
result:
ok single line: '7994'
Test #40:
score: 2
Accepted
time: 4ms
memory: 52644kb
input:
5000 10000 3294 692 1 3294 883 1 3294 57 1 3294 3972 1 3294 3107 1 13 3294 1 4039 4508 2813 4074 4356 4511 760 3294 1 3294 215 1 2281 834 3509 1861 2733 2852 1716 2215 3549 640 3294 1 3294 2215 1 4044 3628 3386 3294 4396 1 2276 3599 3982 1855 2120 3761 4620 2792 2622 259 4461 3361 3294 1794 1 2792 1...
output:
9996
result:
ok single line: '9996'
Test #41:
score: 2
Accepted
time: 4ms
memory: 51096kb
input:
4998 10000 2037 3029 2962 3529 1776 3256 4052 2853 3389 130 1776 3070 3630 2951 1 4846 4531 1 2204 1792 2814 3532 2181 3077 2070 1549 2825 630 2837 1 1172 525 2657 1503 346 1 2772 2432 1 4351 3852 1 991 3154 1 4161 3636 1 1533 3782 1 3839 0 3253 4107 1724 1 2371 441 1 2490 1476 2514 1344 4103 1 1101...
output:
5002
result:
ok single line: '5002'
Test #42:
score: 2
Accepted
time: 6ms
memory: 54276kb
input:
4998 10000 3604 2415 2552 2999 4014 1 2138 3572 2677 4902 1482 1 2339 217 1 638 1323 2662 3600 2998 2506 231 2582 2707 2491 4955 2625 1746 4277 2541 3886 4104 2525 506 1917 2808 4810 3721 1 4841 4081 2551 3925 4360 1 3754 572 1 2777 848 1 4582 864 1 149 2112 2518 2848 1445 1 2681 3254 1 4412 2967 1 ...
output:
6776
result:
ok single line: '6776'
Test #43:
score: 2
Accepted
time: 2ms
memory: 51148kb
input:
4998 10000 1996 2117 3222 4177 4126 3634 1011 1208 2930 2923 3872 2536 4677 2176 1 1239 3704 2689 2726 1986 3364 2985 3118 3279 2271 864 2864 2811 3508 2633 3823 1193 3210 1880 4435 1 867 3420 2632 3687 2910 2730 2020 1769 1 751 2339 1 3410 3910 1 4518 342 2872 1720 1404 1 4945 393 1 4904 4175 1 224...
output:
5593
result:
ok single line: '5593'
Test #44:
score: 2
Accepted
time: 4ms
memory: 51796kb
input:
4998 10000 4804 28 3849 721 2739 2696 1788 1153 1 1598 2007 4146 1345 473 1 1248 1922 2542 517 181 1 4284 3809 2836 860 2718 1 4738 4912 1 2821 4331 1 2375 10 1 2943 2609 3226 3904 389 1 3526 4773 1 2682 1300 1 3221 4571 1 2174 2709 1 1695 2472 3412 3958 480 2568 504 1749 3134 2926 2134 3838 2429 18...
output:
7495
result:
ok single line: '7495'
Test #45:
score: 2
Accepted
time: 5ms
memory: 51860kb
input:
4995 10000 4894 4404 1 2663 3250 3525 1794 3573 3400 4352 2925 2570 4816 3505 2629 4661 613 2539 3418 1376 1 1745 1017 2603 1169 347 1 3945 2997 1 879 1344 3492 4133 2070 1 2116 3625 1 3067 4194 2529 4804 2777 3108 724 879 1 3508 961 1 3708 3515 4459 869 557 1 44 1412 1 4587 2950 3157 1307 2506 1 30...
output:
6662
result:
ok single line: '6662'
Test #46:
score: 2
Accepted
time: 6ms
memory: 52012kb
input:
4989 10000 308 3531 2495 3166 214 1 1550 4139 1 75 3098 1 4700 3912 2495 2472 4255 1 1380 72 1 4375 3042 1 2030 4261 2495 4180 3405 2495 2319 2501 1 1492 3741 1 81 187 1 1327 4535 2495 3405 1851 2495 3515 342 1 2043 3674 1 1680 314 1 3405 2295 2495 1802 349 2495 2366 1840 2495 349 3442 2495 4149 471...
output:
7482
result:
ok single line: '7482'
Test #47:
score: 2
Accepted
time: 7ms
memory: 51728kb
input:
4995 10000 1724 2508 2874 3718 883 2875 1904 2406 1 4855 4627 1 4863 2837 3750 1486 3234 2687 2590 991 3054 3973 1844 3072 2746 2554 1 1093 1639 1 2472 3348 2892 3552 4957 2597 4871 2257 1 2536 4347 3340 4160 1715 4061 930 821 1 645 2536 3428 526 468 3190 4391 3086 4118 712 1277 3042 3277 3971 1 385...
output:
6662
result:
ok single line: '6662'
Test #48:
score: 2
Accepted
time: 4ms
memory: 54752kb
input:
4995 10000 3624 3363 2859 668 4378 2564 488 2100 2994 814 645 3044 3264 3878 2525 3723 2062 1 2701 4514 1 1175 9 1 4659 789 3293 4185 144 1 4898 4832 3146 3360 2869 2505 737 2906 1 2244 2587 1 1540 4658 3620 1803 1598 1 4369 3944 1 38 340 3773 4619 2493 1 1656 4768 3059 3037 2314 1 3890 4371 2647 15...
output:
6662
result:
ok single line: '6662'
Subtask #4:
score: 0
Wrong Answer
Test #49:
score: 6
Accepted
time: 2ms
memory: 38528kb
input:
100 200 98 79 1 40 18 1 45 56 1 23 26 39 88 51 1 49 31 35 55 85 1 5 71 35 88 38 36 30 90 38 73 90 39 83 65 1 80 18 35 91 27 35 39 66 1 96 23 34 30 40 36 60 41 1 78 22 1 25 97 42 98 40 43 33 7 35 58 13 1 7 84 1 4 16 70 88 99 1 24 36 1 40 26 37 30 79 1 27 44 1 44 12 42 84 37 54 50 69 35 18 89 1 93 29 ...
output:
99
result:
ok single line: '99'
Test #50:
score: 6
Accepted
time: 2ms
memory: 38624kb
input:
99 200 47 6 34 5 83 1 22 66 1 40 8 1 17 73 42 52 98 40 80 74 75 82 94 45 35 74 1 32 48 1 75 26 55 59 87 1 14 60 37 68 76 62 30 45 46 56 21 1 74 83 74 68 60 35 40 74 1 68 79 41 10 78 1 16 76 51 85 60 60 33 8 45 70 0 1 86 83 49 3 20 1 3 36 1 86 38 33 9 52 45 15 38 33 93 0 1 93 82 1 98 37 60 50 18 1 33...
output:
98
result:
ok single line: '98'
Test #51:
score: 6
Accepted
time: 4ms
memory: 38264kb
input:
100 200 86 2 1 20 32 1 3 16 1 71 28 52 90 70 1 24 74 1 70 51 34 67 38 48 45 28 38 55 44 1 22 65 38 97 27 37 18 69 1 13 49 1 84 99 1 60 4 39 78 56 1 47 79 1 48 68 40 31 29 1 82 51 40 82 74 41 22 44 35 21 67 35 45 86 51 25 21 36 12 24 53 81 26 1 69 75 1 70 33 1 36 2 36 20 62 1 65 45 35 91 41 1 21 60 4...
output:
132
result:
ok single line: '132'
Test #52:
score: 6
Accepted
time: 1ms
memory: 41624kb
input:
99 200 22 41 33 25 16 1 3 32 1 56 32 38 19 3 37 68 6 36 90 8 37 30 92 33 80 3 37 90 67 34 41 73 37 45 60 1 76 59 1 68 87 35 9 92 36 96 36 1 73 5 33 30 32 33 92 45 33 64 30 1 16 57 1 17 47 1 11 30 36 97 92 41 46 68 1 97 94 37 90 2 34 67 23 1 80 23 40 86 21 1 82 48 1 67 84 38 2 67 35 73 88 1 87 67 37 ...
output:
133
result:
ok single line: '133'
Test #53:
score: 6
Accepted
time: 1ms
memory: 41940kb
input:
99 200 8 5 33 12 88 35 14 71 33 55 53 35 53 91 1 60 26 1 10 8 34 39 94 1 5 53 33 86 16 1 13 36 1 50 62 1 87 89 33 20 26 1 88 73 1 16 82 1 48 67 1 63 72 1 0 12 33 35 94 1 8 28 33 8 52 33 15 75 1 63 0 33 40 28 33 42 41 1 52 87 1 47 14 34 40 71 33 47 71 33 71 63 33 85 95 1 29 38 1 37 69 1 32 24 1 55 14...
output:
150
result:
ok single line: '150'
Test #54:
score: 6
Accepted
time: 0ms
memory: 41852kb
input:
100 200 61 67 71 45 95 35 37 77 58 66 59 79 80 6 1 16 39 90 19 4 46 18 45 60 18 77 61 6 18 1 26 50 91 6 2 1 57 66 46 86 6 1 16 40 40 95 37 52 61 30 62 93 9 52 36 76 39 78 72 91 54 60 51 6 37 1 84 38 57 35 80 40 68 10 39 6 62 1 71 42 78 6 59 1 98 69 67 6 36 1 56 48 46 6 34 1 6 26 1 1 25 56 38 6 1 6 2...
output:
196
result:
ok single line: '196'
Test #55:
score: 6
Accepted
time: 3ms
memory: 42032kb
input:
99 200 50 52 1 40 30 1 41 33 1 95 97 1 51 29 1 92 42 51 25 23 49 76 89 1 7 69 39 45 70 1 74 49 55 49 25 36 6 17 57 66 27 1 48 26 51 18 85 41 87 83 67 58 2 36 85 38 1 13 36 41 26 74 35 41 61 64 50 58 39 69 41 1 42 17 1 0 55 1 93 85 1 49 6 1 85 96 36 42 69 62 67 1 1 51 3 1 48 36 58 19 66 1 33 87 39 9 ...
output:
99
result:
ok single line: '99'
Test #56:
score: 6
Accepted
time: 1ms
memory: 41840kb
input:
99 200 51 10 1 72 59 35 26 82 34 80 20 33 65 87 1 34 79 33 78 49 1 56 6 33 13 27 34 60 78 1 41 46 1 5 0 34 52 49 1 86 94 35 69 36 1 71 77 1 64 75 1 82 7 39 27 22 35 54 37 1 96 46 1 16 38 1 13 83 35 80 60 1 26 86 44 81 35 1 31 14 1 79 20 56 54 47 33 96 73 1 0 41 34 60 19 1 2 95 34 26 29 37 22 37 33 4...
output:
133
result:
ok single line: '133'
Test #57:
score: 6
Accepted
time: 2ms
memory: 41988kb
input:
99 200 48 82 1 81 46 1 7 41 1 8 7 1 28 89 34 74 14 34 15 47 35 94 89 38 63 20 44 32 39 41 49 14 1 83 2 1 63 41 34 36 20 39 68 9 1 80 75 1 23 39 39 20 89 49 68 14 35 28 39 1 11 63 1 36 3 34 64 9 35 9 20 36 12 10 1 45 2 36 23 14 56 71 74 33 32 20 37 20 23 46 72 86 1 45 68 59 54 94 1 95 2 1 45 51 1 33 ...
output:
110
result:
ok single line: '110'
Test #58:
score: 6
Accepted
time: 3ms
memory: 38172kb
input:
96 200 91 78 1 94 25 42 59 66 1 7 36 1 68 16 33 46 16 1 94 81 35 50 16 33 93 48 1 29 60 1 58 42 1 37 81 33 63 1 32 28 41 1 17 78 1 33 71 1 68 74 33 8 5 1 21 25 40 35 23 37 85 23 33 57 73 1 90 95 1 13 67 33 75 32 38 82 46 1 21 69 33 22 39 1 38 5 1 43 75 32 79 82 32 43 13 1 92 83 1 1 75 1 38 36 1 23 1...
output:
126
result:
ok single line: '126'
Test #59:
score: 0
Wrong Answer
time: 2ms
memory: 38312kb
input:
99 200 11 6 36 54 82 1 61 84 1 56 90 1 17 73 1 5 17 37 34 6 38 81 74 34 27 88 1 42 25 1 30 16 1 10 46 36 25 39 1 27 82 36 59 82 33 7 1 1 22 29 40 38 94 34 22 74 33 76 8 1 98 5 37 22 38 34 27 77 34 59 24 1 45 44 1 18 28 1 62 67 1 86 26 1 31 41 1 54 88 36 4 70 35 9 98 34 90 65 1 32 97 1 98 16 38 29 98...
output:
133
result:
wrong answer 1st lines differ - expected: '131', found: '133'
Subtask #5:
score: 0
Wrong Answer
Test #63:
score: 2
Accepted
time: 3ms
memory: 42792kb
input:
500 1000 208 211 175 291 249 178 221 407 234 95 379 1 455 400 1 28 217 1 488 93 1 398 101 191 382 222 184 407 77 191 183 471 1 306 466 1 174 78 175 391 180 167 432 486 1 414 284 171 436 446 1 34 294 1 38 110 1 41 186 1 148 336 1 85 33 1 491 114 171 22 197 1 385 388 183 245 41 176 423 257 1 100 203 1...
output:
499
result:
ok single line: '499'
Test #64:
score: 2
Accepted
time: 2ms
memory: 42292kb
input:
499 1000 129 32 1 83 112 369 275 120 1 123 382 168 316 326 244 238 349 257 7 103 207 21 468 319 479 269 1 156 66 1 312 351 1 80 299 1 413 306 1 155 240 1 306 87 305 67 188 188 481 271 230 122 77 1 285 491 1 120 247 288 454 158 1 12 459 1 447 139 1 429 399 308 217 200 1 87 468 195 93 81 1 405 165 187...
output:
498
result:
ok single line: '498'
Test #65:
score: 2
Accepted
time: 2ms
memory: 45828kb
input:
499 1000 179 207 191 269 207 167 454 87 1 258 456 1 267 19 1 400 387 1 261 326 1 383 246 219 193 388 198 219 278 173 476 71 1 331 289 1 36 427 194 152 285 221 352 419 1 325 5 1 104 89 1 67 279 178 445 300 1 486 280 201 414 486 231 339 435 1 346 21 1 384 3 1 369 362 1 297 416 1 498 408 1 55 374 1 460...
output:
664
result:
ok single line: '664'
Test #66:
score: 0
Wrong Answer
time: 0ms
memory: 45024kb
input:
498 1000 448 224 187 395 147 1 241 251 1 95 443 168 240 273 166 363 15 1 128 157 182 304 461 176 387 305 1 165 72 182 213 410 175 325 187 1 242 86 189 135 181 1 80 262 181 203 293 1 287 434 170 128 301 170 88 86 194 472 288 174 32 239 1 339 103 1 497 417 168 448 288 1 234 51 174 55 382 186 326 444 1...
output:
670
result:
wrong answer 1st lines differ - expected: '663', found: '670'
Subtask #6:
score: 0
Wrong Answer
Test #77:
score: 3
Accepted
time: 7ms
memory: 51920kb
input:
5000 10000 1233 3822 1672 230 3287 1 3304 542 1 4203 4319 1 3890 46 1 1145 4330 1865 4631 4227 1667 3806 541 1 3145 196 1846 2583 4656 1 2526 3928 1 1339 2914 1 448 438 1945 3691 4076 2605 2115 2224 1727 3050 4573 1876 334 4820 1725 4792 2439 1 279 787 1 3592 4602 1704 3634 3783 1 4822 424 1687 1546...
output:
4999
result:
ok single line: '4999'
Test #78:
score: 3
Accepted
time: 7ms
memory: 51700kb
input:
4999 10000 1536 2256 2503 1838 4182 1 4242 4573 1 4453 4031 2797 4843 4842 2784 701 2457 1906 1106 324 2586 4432 424 3795 496 930 2340 2468 1024 1 2922 4574 1882 1640 4939 1 2452 2963 1 1659 308 1 346 1011 1 2490 2062 1 3519 664 1 1252 1603 1 1095 737 1 3444 573 1 4448 1092 1 262 4248 3240 4244 1059...
output:
4998
result:
ok single line: '4998'
Test #79:
score: 3
Accepted
time: 3ms
memory: 51180kb
input:
4999 10000 1756 464 1 2256 3527 1779 3158 662 1979 648 4209 1 131 4844 2373 4768 1977 1 4338 2206 1 3900 1283 1764 3656 4458 1 642 1292 1 3377 1257 1734 3228 4789 1 2418 3295 2112 4489 3040 1947 4604 4945 2171 1761 4027 1 1770 88 1 4217 1453 1 4732 4196 2069 2042 2568 1 172 286 2163 1578 4021 2125 1...
output:
6664
result:
ok single line: '6664'
Test #80:
score: 0
Wrong Answer
time: 2ms
memory: 54524kb
input:
4998 10000 1903 2765 1 632 985 1726 4097 2231 2043 3670 1055 1690 95 336 1 4153 3229 1 3338 3891 1 774 4667 1 3384 834 1 2304 3193 1667 1991 4811 1 1566 764 1 1509 2702 1 4769 1895 1 2116 2290 1865 1030 2843 1700 3653 3081 1 4269 4090 1 3591 213 1 2069 2206 1 3987 2621 1 3694 427 1760 2443 4937 2065...
output:
6722
result:
wrong answer 1st lines differ - expected: '6694', found: '6722'
Subtask #7:
score: 0
Wrong Answer
Test #91:
score: 5
Accepted
time: 72ms
memory: 66092kb
input:
79998 160000 47319 43920 27006 37874 58542 1 2314 12853 1 36506 22858 26740 68911 13350 31720 25597 38100 1 64407 54997 1 51674 45889 26896 6348 21021 1 20123 37354 1 40529 9510 1 17862 77380 1 33670 44212 1 49850 17554 1 66696 36952 26977 68826 79479 1 57060 12489 1 5752 45575 1 7053 19904 26742 66...
output:
106662
result:
ok single line: '106662'
Test #92:
score: 5
Accepted
time: 76ms
memory: 69064kb
input:
79995 160000 61320 66228 31633 20416 6828 26745 65430 51513 28853 61601 77927 1 33775 10749 30386 33489 57662 28107 65564 42605 1 72503 58487 28031 24791 62445 1 361 36744 31994 6993 12131 1 38636 9267 30756 50189 3424 27481 21764 13079 27045 13091 75180 1 76213 1089 29713 29054 60322 28242 6840 342...
output:
106661
result:
ok single line: '106661'
Test #93:
score: 0
Wrong Answer
time: 70ms
memory: 65720kb
input:
79989 160000 32970 17371 1 51500 77845 1 8694 39321 1 33402 55053 1 3593 13400 1 25018 73843 1 10116 78323 39829 12333 8162 1 77825 52478 39800 71287 49773 39857 69284 34436 1 58422 323 1 71978 34401 1 32727 4966 39931 17840 59434 1 78584 5862 1 33173 8137 39835 35430 76217 1 77630 21975 1 39606 180...
output:
119981
result:
wrong answer 1st lines differ - expected: '119980', found: '119981'
Subtask #8:
score: 0
Wrong Answer
Test #105:
score: 4
Accepted
time: 1379ms
memory: 133040kb
input:
500000 2000000 492952 221541 267388 189147 466806 1 176713 26739 184225 184178 191476 193886 268077 21780 170551 226184 221541 302897 9942 461890 1 221541 343066 171790 495977 267797 176982 213497 330126 205211 128338 411248 1 283722 405246 217711 18538 208366 1 164175 376442 254213 29263 221541 171...
output:
499999
result:
ok single line: '499999'
Test #106:
score: 4
Accepted
time: 1342ms
memory: 132096kb
input:
499999 2000000 338233 340347 226535 38717 379987 168389 336194 116029 1 177994 341315 1 324318 325023 189015 407991 59970 1 363275 468224 1 20980 497440 167304 173157 482862 194272 268329 191991 167875 493110 59848 176331 167640 301032 1 38980 608 1 451792 351819 1 466507 16056 313310 159434 426922 ...
output:
499998
result:
ok single line: '499998'
Test #107:
score: 4
Accepted
time: 1189ms
memory: 128572kb
input:
499999 2000000 225504 367124 184692 13152 368884 1 246115 310825 1 85546 260802 1 36120 263251 1 347061 457515 179247 391512 418943 209628 488000 251230 202554 342387 451505 218204 250597 6360 1 314794 356575 167579 379921 169405 175694 238333 100765 213326 23010 256301 1 138786 206212 195538 119086...
output:
666664
result:
ok single line: '666664'
Test #108:
score: 4
Accepted
time: 1147ms
memory: 122844kb
input:
499998 2000000 239843 21834 170623 83053 349534 191770 82825 125117 173513 250882 82203 1 84947 381078 166941 22652 453627 182123 335543 360105 177097 80826 287621 170686 199733 323380 189528 158984 68066 181722 35365 34669 1 21279 239681 179131 219384 62879 170013 2795 18867 169707 126894 379453 22...
output:
667017
result:
ok single line: '667017'
Test #109:
score: 4
Accepted
time: 1090ms
memory: 121264kb
input:
499998 2000000 355742 293959 1 136181 26342 1 218741 137151 176534 404921 174940 167299 469296 27392 167588 107859 266624 1 244790 166337 184474 189980 367073 1 157285 29642 189173 172758 406073 1 491913 225316 168779 294380 307097 170056 130008 50345 170049 154969 497856 166717 290947 132729 169680...
output:
767066
result:
ok single line: '767066'
Test #110:
score: 4
Accepted
time: 405ms
memory: 102244kb
input:
500000 2000000 476350 51962 1 476350 292722 1 294805 128846 449372 476350 423345 1 174567 270229 300541 476350 349849 1 120425 488728 235975 419354 55151 169452 476350 17712 1 467841 387986 291040 378472 34286 435949 397453 133063 264757 476350 146174 1 67353 363976 275957 196278 467016 343330 42663...
output:
999996
result:
ok single line: '999996'
Test #111:
score: 4
Accepted
time: 1309ms
memory: 133672kb
input:
499998 2000000 366610 387449 1 374528 86585 1 488325 386540 186356 477280 490684 171522 348324 425830 178981 96980 287110 181522 261528 417619 282357 139407 292432 195815 455017 373830 193821 218772 308990 227996 478845 171275 1 483395 134664 1 97023 120267 168469 5305 177167 169835 68601 332163 202...
output:
500004
result:
ok single line: '500004'
Test #112:
score: 4
Accepted
time: 1093ms
memory: 127128kb
input:
499998 2000000 331665 475012 1 121152 81914 176809 496682 420400 195245 155426 411058 168700 35401 302515 1 225443 370393 1 296555 22177 172708 337088 40800 166685 184844 171421 183185 197144 289143 179437 185993 368 212093 12939 192391 1 200685 376931 1 187169 394076 1 412288 381560 178914 445940 1...
output:
678343
result:
ok single line: '678343'
Test #113:
score: 4
Accepted
time: 1153ms
memory: 133876kb
input:
499998 2000000 319770 442556 1 213924 152866 1 2496 220932 1 437667 82087 177822 457316 266598 282010 239438 454138 175650 252742 72788 1 128488 358061 170500 311235 86405 1 21931 428775 1 333079 442421 238809 140368 456692 264623 85342 498107 229485 371864 380837 179159 319641 441750 172196 11371 4...
output:
555738
result:
ok single line: '555738'
Test #114:
score: 4
Accepted
time: 1136ms
memory: 123300kb
input:
499998 2000000 219926 205092 1 205001 189575 180932 262831 159394 170969 16230 32730 185535 486101 491141 1 69290 486917 172380 188392 125635 167512 183179 50494 167940 390213 10114 185124 51935 210969 168058 37203 325999 177597 165891 391917 167084 469411 62267 174273 171686 6617 198217 29770 91370...
output:
666662
result:
ok single line: '666662'
Test #115:
score: 4
Accepted
time: 1191ms
memory: 127804kb
input:
499995 2000000 184364 177119 1 396742 248057 172628 34398 223566 167004 313764 382786 197485 20867 481289 166931 1599 357588 1 352987 447229 227058 32679 234774 183814 300469 441974 175154 346072 388083 169493 76799 436148 166706 417637 97043 219697 305219 418013 167159 243066 349589 182332 290242 1...
output:
666661
result:
ok single line: '666661'
Test #116:
score: 0
Wrong Answer
time: 1080ms
memory: 123484kb
input:
499989 2000000 467454 448035 249923 206609 192057 249733 486230 447304 249865 262080 104809 249816 360622 267254 249260 73644 380935 1 81733 362647 249458 135629 497166 249719 276985 226667 249858 406381 61291 249775 54689 335340 249427 234880 224555 249794 493610 241933 249411 196987 103975 249297 ...
output:
749981
result:
wrong answer 1st lines differ - expected: '749980', found: '749981'