QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#323202 | #7737. Extending Distance | complexor | AC ✓ | 666ms | 12268kb | C++23 | 5.4kb | 2024-02-08 20:26:20 | 2024-02-08 20:26:21 |
Judging History
answer
#include <bits/stdc++.h>
#define clr(f, n) memset(f, 0, (n) << 2)
#define cpy(f, g, n) memcpy(f, g, (n) << 2)
typedef long long LL;
typedef unsigned long long ULL;
typedef __int128 LLL;
typedef std::pair<int, int> pii;
typedef std::pair<LL, LL> pll;
#define MP std::make_pair
#define fi first
#define se second
int read()
{
int s = 0, f = 1;
char c = getchar();
while (!(c >= '0' && c <= '9'))
f ^= (c == '-'), c = getchar();
while (c >= '0' && c <= '9')
s = s * 10 + (c ^ 48), c = getchar();
return f ? s : -s;
}
const int MAXN = 505, MAXM = 100005;
const LL INF = 0x3f3f3f3f3f3f3f3fll;
int n, m, r[MAXN][MAXN], d[MAXN][MAXN], K, N;
int S, T;
LL dist[MAXN][MAXN];
int nxt[MAXM], to[MAXM], cst[MAXM], pre[MAXN], tot = -1;
int L[MAXN][MAXN], R[MAXN][MAXN], U[MAXN][MAXN], D[MAXN][MAXN];
int head[MAXN], cur[MAXN];
LL cap[MAXM];
void add_edge(int u, int v, LL w, int c)
{ to[++tot] = v, nxt[tot] = head[u], cap[tot] = w, cst[tot] = c, head[u] = tot; }
void add_net(int u, int v, LL w, int c)
{ add_edge(u, v, w, c), add_edge(v, u, 0, -c); }
LL dis[MAXN];
bool vis[MAXN];
pll dfs(int x, LL lim)
{
if (vis[x]) return MP(0, 0);
if (x == T) return MP(lim, 0);
vis[x] = true;
LL F = 0, C = 0;
for (int &e = cur[x]; ~e; e = nxt[e])
if (cap[e] && dis[to[e]] == dis[x] + cst[e])
{
pll tmp = dfs(to[e], std::min(lim, cap[e]));
F += tmp.fi, C += tmp.fi * cst[e] + tmp.se;
lim -= tmp.fi, cap[e] -= tmp.fi, cap[e ^ 1] += tmp.fi;
if (!lim) return MP(F, C);
}
return MP(F, C);
}
bool modify()
{
if (vis[T]) return true;
LL mn = INF;
for (int i = 1; i <= N; i++) if (vis[i])
for (int e = head[i]; ~e; e = nxt[e])
if (cap[e] && !vis[to[e]])
mn = std::min(dis[i] + cst[e] - dis[to[e]], mn);
if (mn >= INF) return false;
for (int i = 1; i <= N; i++)
if (vis[i]) dis[i] -= mn;
return true;
}
pll MCMF()
{
LL F = 0, C = 0;
memset(dis + 1, 0, N << 3);
dis[S] = -INF;
do
{
memset(vis + 1, false, N);
memcpy(cur + 1, head + 1, N << 2);
pll res = dfs(S, INF);
F += res.fi, C += res.se;
} while (modify()) ;
return MP(F, C);
}
struct Node
{
int x, y; LL d;
Node(){}
Node(int _x, int _y, LL _d)
: x(_x), y(_y), d(_d) {}
friend bool operator<(Node a, Node b)
{ return a.d > b.d; }
} ;
void Dijkstra()
{
static bool vis[MAXN][MAXN];
static std::priority_queue<Node> q;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
dist[i][j] = INF, vis[i][j] = false;
for (int i = 1; i <= n; i++)
q.emplace(i, 1, dist[i][1] = 0);
while (!q.empty())
{
Node x = q.top(); q.pop();
if (vis[x.x][x.y]) continue;
vis[x.x][x.y] = true;
if (x.x < n && dist[x.x + 1][x.y] > x.d + d[x.x][x.y])
q.emplace(x.x + 1, x.y, dist[x.x + 1][x.y] = x.d + d[x.x][x.y]);
if (x.x > 1 && dist[x.x - 1][x.y] > x.d + d[x.x - 1][x.y])
q.emplace(x.x - 1, x.y, dist[x.x - 1][x.y] = x.d + d[x.x - 1][x.y]);
if (x.y < m && dist[x.x][x.y + 1] > x.d + r[x.x][x.y])
q.emplace(x.x, x.y + 1, dist[x.x][x.y + 1] = x.d + r[x.x][x.y]);
if (x.y > 1 && dist[x.x][x.y - 1] > x.d + r[x.x][x.y - 1])
q.emplace(x.x, x.y - 1, dist[x.x][x.y - 1] = x.d + r[x.x][x.y - 1]);
}
}
int main()
{
for (int Tcnt = read(), id = Tcnt; Tcnt--; )
{
n = read(), m = read(), K = read();
for (int i = 1; i <= n; i++)
for (int j = 1; j < m; j++)
r[i][j] = read();
for (int i = 1; i < n; i++)
for (int j = 1; j <= m; j++)
d[i][j] = read();
Dijkstra();
LL lim = INF;
for (int i = 1; i <= n; i++)
lim = std::min(dist[i][m], lim);
lim += K;
// printf("%d\n", lim);
N = (n - 1) * (m - 1);
S = ++N, T = ++N;
int s = ++N, t = ++N;
memset(head + 1, -1, N << 2), tot = -1;
add_net(S, s, lim, 0), add_net(t, T, lim, 0);
#define id(i, j) (((i) - 1) * (m - 1) + (j))
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
L[i][j] = R[i][j] = U[i][j] = D[i][j] = -1;
for (int i = 1; i < m; i++)
{
add_net(s, id(1, i), r[1][i], 0);
add_net(s, id(1, i), INF, 1), R[1][i] = tot;
}
for (int i = 1; i < m; i++)
{
add_net(id(n - 1, i), t, r[n][i], 0);
add_net(id(n - 1, i), t, INF, 1), R[n][i] = tot;
}
for (int i = 1; i < n - 1; i++)
for (int j = 1; j < m; j++)
{
add_net(id(i, j), id(i + 1, j), r[i + 1][j], 0);
add_net(id(i, j), id(i + 1, j), INF, 1), R[i + 1][j] = tot;
add_net(id(i + 1, j), id(i, j), r[i + 1][j], 0);
add_net(id(i + 1, j), id(i, j), INF, 1), L[i + 1][j + 1] = tot;
}
for (int i = 1; i < n; i++)
for (int j = 1; j < m - 1; j++)
{
add_net(id(i, j), id(i, j + 1), d[i][j + 1], 0);
add_net(id(i, j), id(i, j + 1), INF, 1), D[i][j + 1] = tot;
add_net(id(i, j + 1), id(i, j), d[i][j + 1], 0);
add_net(id(i, j + 1), id(i, j), INF, 1), U[i + 1][j + 1] = tot;
}
printf("%lld\n", MCMF().se);
// if (id == 40) continue;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
{
if (~L[i][j] && cap[L[i][j]]) r[i][j - 1] += cap[L[i][j]];
if (~R[i][j] && cap[R[i][j]]) r[i][j] += cap[R[i][j]];
if (~D[i][j] && cap[D[i][j]]) d[i][j] += cap[D[i][j]];
if (~U[i][j] && cap[U[i][j]]) d[i - 1][j] += cap[U[i][j]];
}
for (int i = 1; i <= n; i++)
for (int j = 1; j < m; j++)
printf("%d%c", r[i][j], " \n"[j + 1 == m]);
for (int i = 1; i < n; i++)
for (int j = 1; j <= m; j++)
printf("%d%c", d[i][j], " \n"[j == m]);
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 12088kb
input:
2 3 4 6 2 1 15 7 1 9 13 3 2 3 6 1 2 5 2 15 3 3 3 3 1 1 2 2 3 3 1 1 1 2 2 2
output:
9 2 1 15 8 1 9 13 3 5 3 6 6 2 5 2 15 3 4 1 4 2 3 3 3 1 1 1 2 2 2
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 4ms
memory: 12100kb
input:
125 4 4 48 33 9 39 38 74 3 18 44 9 20 91 19 76 95 17 16 61 88 50 49 68 18 33 84 4 4 14 54 69 42 47 90 28 2 73 59 1 20 90 43 22 74 19 27 67 46 43 42 21 78 80 4 4 93 12 67 38 13 85 39 74 68 77 71 80 64 92 97 53 46 66 6 30 20 66 70 71 24 4 4 34 43 86 55 49 34 73 78 77 90 99 49 5 55 4 63 47 80 24 15 3 8...
output:
87 33 38 39 38 74 22 37 44 29 20 91 19 76 95 17 16 61 88 50 49 68 18 33 84 14 54 69 42 47 90 28 2 73 59 1 20 104 43 22 74 19 27 67 46 43 42 21 78 80 166 12 79 119 59 85 66 74 68 77 71 80 64 92 97 53 46 66 6 30 20 66 70 71 24 34 43 86 55 49 34 73 78 77 90 99 49 9 55 4 63 47 80 24 45 3 85 12 6 31 45 4...
result:
ok Correct. (125 test cases)
Test #3:
score: 0
Accepted
time: 6ms
memory: 12028kb
input:
80 5 5 97 10 18 14 13 17 15 16 11 15 10 14 15 12 17 12 15 12 11 15 15 19 19 13 19 19 19 17 10 10 19 12 13 18 11 20 12 17 14 13 12 5 5 65 13 15 13 20 18 19 13 20 10 19 18 17 19 19 11 14 12 18 11 10 18 14 18 19 18 20 11 17 11 17 16 13 19 18 13 16 14 17 11 18 5 5 3 15 10 10 18 17 17 17 14 13 15 15 19 1...
output:
473 10 18 14 108 26 15 20 89 35 16 20 79 48 17 17 68 57 20 18 55 19 19 13 19 19 19 17 10 10 19 12 13 18 11 20 12 17 14 13 12 271 13 15 13 75 27 19 14 56 34 19 18 45 42 24 11 39 36 18 16 46 18 14 18 19 18 20 11 17 11 17 16 13 19 18 13 16 14 17 11 18 3 15 10 10 21 17 17 17 14 13 15 15 19 10 18 16 17 1...
result:
ok Correct. (80 test cases)
Test #4:
score: 0
Accepted
time: 7ms
memory: 12032kb
input:
55 6 6 98 943830625 154853276 396311720 585129723 216006508 789713291 522861691 174874210 616414184 931597164 831871942 149821142 520941619 814161584 200419736 646044877 574761262 188910317 673355715 723256093 264106685 163628126 318085983 226850181 101764170 179381345 486537031 346100002 805792579 ...
output:
98 943830625 154853276 396311720 585129723 216006508 789713291 522861691 174874210 616414184 931597164 831871942 149821142 520941619 814161584 200419736 646044877 574761262 188910317 673355715 723256093 264106685 163628126 318085983 226850279 101764170 179381345 486537031 346100002 805792579 5081942...
result:
ok Correct. (55 test cases)
Test #5:
score: 0
Accepted
time: 3ms
memory: 12096kb
input:
55 6 6 96 16739843 17336211 10384494 17185421 10646458 18552039 13790956 13642043 10307995 14193711 19297204 12810329 18681558 18724838 16636750 11505737 19658923 19307194 12241535 15070027 16123862 17524159 19471242 14316479 10954501 10604286 17691735 17352365 14092770 19909253 11761060 19372581 16...
output:
96 16739843 17336211 10384494 17185421 10646458 18552039 13790956 13642043 10307995 14193807 19297204 12810329 18681558 18724838 16636750 11505737 19658923 19307194 12241535 15070027 16123862 17524159 19471242 14316479 10954501 10604286 17691735 17352365 14092770 19909253 11761060 19372581 16863139 ...
result:
ok Correct. (55 test cases)
Test #6:
score: 0
Accepted
time: 4ms
memory: 12032kb
input:
40 7 7 17 27500 8466 7754 5254 45204 36821 35457 23725 45494 26962 24728 31437 46232 38720 23756 17265 21004 25959 29727 6060 23244 45236 39610 23968 17068 14954 9745 28949 20957 30885 8272 49710 28660 17038 12058 48058 10306 5065 45011 25264 25765 17423 21072 22743 17503 11324 10214 6879 22253 1729...
output:
17 27500 8466 7754 5254 45204 36821 35457 23725 45494 26962 24728 31454 46232 38720 23756 17265 21004 25959 29727 6060 23244 45236 39610 23968 17068 14954 9745 28949 20957 30885 8272 49710 28660 17038 12058 48058 10306 5065 45011 25264 25765 17423 21072 22743 17503 11324 10214 6879 22253 17295 49299...
result:
ok Correct. (40 test cases)
Test #7:
score: 0
Accepted
time: 13ms
memory: 12068kb
input:
31 8 8 84 82373 175391 615535 844446 885043 54908 235817 174599 782716 140021 505505 551220 980613 844864 490309 720051 436451 436322 357173 349094 303200 428983 865478 890817 50236 172208 96832 261006 265321 413840 490656 677420 172238 872751 182871 957260 978182 971447 603592 37811 282590 470570 1...
output:
84 82373 175391 615535 844446 885043 54908 235817 174599 782716 140021 505505 551220 980613 844864 490309 720051 436451 436322 357173 349094 303200 428983 865478 890817 50236 172208 96832 261090 265321 413840 490656 677420 172238 872751 182871 957260 978182 971447 603592 37811 282590 470570 134862 3...
result:
ok Correct. (31 test cases)
Test #8:
score: 0
Accepted
time: 13ms
memory: 12044kb
input:
24 9 9 80 178 146 100 118 196 180 100 110 153 125 200 139 174 169 163 196 173 167 120 182 172 142 188 132 160 150 148 171 162 125 180 152 159 152 161 177 106 129 152 114 179 132 146 126 107 148 141 151 165 123 151 153 112 151 148 182 105 188 136 199 173 192 117 118 116 190 103 198 125 150 105 118 15...
output:
227 178 146 100 118 196 180 100 167 153 125 200 139 174 169 163 196 173 167 120 182 172 142 188 132 160 150 148 171 162 125 180 152 159 152 161 177 106 129 152 149 214 132 146 126 107 148 141 171 165 123 151 153 112 151 148 182 105 188 136 199 173 192 117 118 116 190 103 198 125 150 105 198 157 130 ...
result:
ok Correct. (24 test cases)
Test #9:
score: 0
Accepted
time: 8ms
memory: 12052kb
input:
20 10 10 91 90000001 90000000 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000001 90000001 90000001 90000001 90000001 90000001 90000001 90000000 90000000 90000000 90000001 90000000 90000000 90000000 90000001 90000001 90000001 90000000 ...
output:
886 90000001 90000000 90000001 90000000 90000001 90000000 90000000 90000001 90000090 90000087 90000001 90000001 90000001 90000000 90000001 90000001 90000001 90000001 90000001 90000001 90000001 90000000 90000000 90000000 90000001 90000000 90000090 90000087 90000001 90000001 90000001 90000000 90000001...
result:
ok Correct. (20 test cases)
Test #10:
score: 0
Accepted
time: 24ms
memory: 10152kb
input:
10 14 14 68 20 23 20 22 23 26 23 22 28 30 25 20 29 22 30 26 20 22 21 26 23 23 22 22 22 21 24 29 30 30 24 20 25 23 30 27 27 26 24 30 25 25 24 26 26 23 22 22 30 24 20 23 27 24 29 24 22 24 21 20 20 28 24 21 28 20 24 25 29 20 30 30 30 30 24 27 23 28 29 25 25 26 21 27 23 25 25 27 23 27 23 23 22 27 27 29 ...
output:
607 20 23 20 22 23 26 23 22 28 30 25 20 86 33 30 26 20 22 21 26 23 26 31 27 22 61 40 29 30 30 24 20 25 23 30 27 27 26 37 43 25 25 24 26 26 23 22 30 30 24 22 48 41 24 29 34 22 24 22 20 20 28 24 21 59 38 24 30 29 20 30 30 30 30 24 27 27 29 30 25 25 26 21 27 23 33 31 27 23 27 50 38 22 27 27 29 30 25 24...
result:
ok Correct. (10 test cases)
Test #11:
score: 0
Accepted
time: 19ms
memory: 12080kb
input:
10 10 20 79 1001 1003 1000 1003 1001 1003 1002 1003 1001 1003 1003 1000 1001 1001 1001 1002 1002 1003 1002 1001 1003 1001 1001 1001 1000 1003 1002 1000 1002 1001 1001 1003 1000 1001 1003 1001 1001 1000 1001 1003 1000 1002 1003 1003 1003 1001 1002 1002 1000 1002 1003 1001 1003 1000 1002 1000 1002 100...
output:
732 1001 1003 1000 1003 1001 1003 1002 1003 1001 1003 1003 1000 1001 1001 1001 1002 1002 1003 1070 1069 1003 1001 1001 1001 1000 1003 1002 1000 1002 1001 1001 1003 1000 1001 1003 1001 1001 1010 1003 1003 1000 1002 1003 1003 1003 1001 1002 1002 1000 1002 1003 1001 1003 1000 1002 1000 1070 1070 1003 1...
result:
ok Correct. (10 test cases)
Test #12:
score: 0
Accepted
time: 42ms
memory: 12164kb
input:
10 20 10 21 777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489 769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946 30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510 125777481 136448711 5...
output:
21 777601561 917773453 313011120 861769383 651010533 771534309 418153755 749795307 939533489 769621271 705696594 863041783 330858635 136276987 569175453 21935211 559486868 264609946 30013079 725693020 492377730 630078388 365743281 693415122 589281054 690370363 47310510 125777502 136448711 508925654 ...
result:
ok Correct. (10 test cases)
Test #13:
score: 0
Accepted
time: 5ms
memory: 12128kb
input:
24 6 2 37 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 18 13 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...
output:
222 38 38 38 38 38 38 1 1 1 1 1 1 1 1 1 1 117 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 12 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 11 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 9 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 8 1 1 1 1 1...
result:
ok Correct. (24 test cases)
Test #14:
score: 0
Accepted
time: 9ms
memory: 12116kb
input:
31 9 3 33 1 5 4 5 3 4 4 2 5 3 4 3 2 5 5 5 4 3 5 1 4 2 1 2 1 5 3 5 3 2 2 3 2 3 5 3 4 4 3 1 4 2 2 3 4 3 2 5 2 1 3 5 12 6 72 2 2 1 1 5 1 2 5 1 4 5 5 1 2 3 4 1 4 4 4 1 2 2 2 5 5 5 3 5 3 2 1 1 3 5 4 1 4 2 1 4 2 1 5 3 3 3 2 4 5 5 5 2 3 3 4 3 4 5 1 3 5 5 5 1 1 5 5 3 2 5 3 5 3 1 4 3 3 5 4 5 1 3 5 2 3 3 5 4 ...
output:
284 3 36 4 35 5 34 10 29 13 26 16 23 21 18 19 20 18 21 5 1 4 2 1 2 1 5 3 5 3 2 2 3 2 3 5 3 4 4 3 1 4 2 6 3 6 6 3 1 3 5 803 2 2 3 5 70 5 2 5 1 69 5 5 4 4 64 8 3 6 4 61 9 2 7 6 58 9 5 9 5 54 13 5 3 8 53 17 3 4 7 51 18 3 8 5 48 23 3 7 6 43 24 5 5 6 42 24 6 5 9 38 3 5 5 5 1 1 5 5 3 2 5 3 5 3 1 4 3 3 5 4...
result:
ok Correct. (31 test cases)
Test #15:
score: 0
Accepted
time: 11ms
memory: 12168kb
input:
27 14 3 50 998244355 998244354 998244353 998244355 998244355 998244354 998244353 998244353 998244353 998244354 998244353 998244354 998244355 998244353 998244354 998244354 998244355 998244354 998244354 998244354 998244355 998244355 998244354 998244355 998244354 998244355 998244354 998244353 998244354...
output:
670 998244355 998244401 998244400 998244356 998244355 998244401 998244401 998244355 998244354 998244402 998244401 998244355 998244355 998244401 998244402 998244354 998244355 998244401 998244401 998244355 998244355 998244401 998244401 998244355 998244354 998244402 998244403 998244353 998244354 998244...
result:
ok Correct. (27 test cases)
Test #16:
score: 0
Accepted
time: 12ms
memory: 12144kb
input:
23 20 8 97 65608 5872 94352 46988 59846 12493 44992 76156 71668 37922 41038 63074 89348 52169 86215 13124 34107 56625 89609 74457 68595 4701 48937 41711 40122 4771 27822 49478 44146 33934 94003 46579 70799 92669 73897 74846 46044 73186 49298 7012 81846 33315 73703 6101 59247 53180 31956 19735 66252 ...
output:
97 65608 5872 94352 46988 59846 12493 44992 76156 71668 37922 41038 63074 89348 52169 86215 13124 34107 56625 89609 74457 68595 4701 48937 41711 40122 4771 27822 49575 44146 33934 94003 46579 70799 92669 73897 74846 46044 73186 49298 7012 81846 33315 73703 6101 59247 53180 31956 19735 66252 16794 81...
result:
ok Correct. (23 test cases)
Test #17:
score: 0
Accepted
time: 122ms
memory: 12080kb
input:
19 8 19 24 902387291 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804932 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049 971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778...
output:
24 902387291 907620818 994686428 993181541 945788800 985461854 930840176 976723143 978273460 908804932 947598154 948392387 906663045 945746194 935677070 906756920 944967394 995192049 971027077 958873510 947130283 938614195 938536007 978161927 948149370 943899083 936971628 979751238 924273778 9948463...
result:
ok Correct. (19 test cases)
Test #18:
score: 0
Accepted
time: 11ms
memory: 12240kb
input:
17 8 6 73 454 453 255 154 145 234 372 334 453 446 475 154 423 475 172 348 129 504 471 299 381 454 313 281 135 313 366 411 397 449 137 361 216 132 284 231 127 338 217 508 7722 2335 6535 3174 7625 7253 1724 4688 3487 5118 746 2569 1333 8705 5312 7854 7121 8830 1497 1091 1873 8673 7066 9654 6715 1904 6...
output:
73 454 453 255 154 145 234 372 334 453 446 475 154 423 475 172 348 129 504 471 299 381 454 313 281 135 313 366 411 397 449 137 361 216 132 357 231 127 338 217 508 7722 2335 6535 3174 7625 7253 1724 4688 3487 5118 746 2569 1333 8705 5312 7854 7121 8830 1497 1091 1873 8673 7066 9654 6715 1904 6931 130...
result:
ok Correct. (17 test cases)
Test #19:
score: 0
Accepted
time: 0ms
memory: 12268kb
input:
23 88 2 97 841315194 845068923 970975198 957201780 251777303 404708591 2727155 669564257 336704019 803214539 649487089 931208031 194958628 208113257 766983395 773886317 969081031 767526283 94213588 872004907 742843321 70045653 828417878 78044768 948026239 74041166 698029055 507301238 56824543 257615...
output:
97 841315194 845068923 970975198 957201780 251777303 404708591 2727252 669564257 336704019 803214539 649487089 931208031 194958628 208113257 766983395 773886317 969081031 767526283 94213588 872004907 742843321 70045653 828417878 78044768 948026239 74041166 698029055 507301238 56824543 257615587 9794...
result:
ok Correct. (23 test cases)
Test #20:
score: 0
Accepted
time: 9ms
memory: 12112kb
input:
19 2 75 29 919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794361 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 79...
output:
29 919738918 817415784 547071389 765591923 840765371 272558012 857925393 355491607 630197873 232681522 488447662 651935225 655063717 94077244 436556672 393624718 961794361 486877806 959891293 894435244 411013650 92339205 12625243 190596368 124067993 451522398 927510612 174581723 914056251 791511418 ...
result:
ok Correct. (19 test cases)
Test #21:
score: 0
Accepted
time: 2ms
memory: 12036kb
input:
1 5 6 10 1 1 1 1 100 1 1 2 100 100 100 1 1 1 100 100 100 2 1 1 100 1 1 1 1 1 100 100 100 1 100 100 100 100 2 1 100 100 1 2 100 100 100 100 1 100 100 100 1
output:
10 1 1 1 1 100 1 1 2 100 100 100 1 10 1 100 100 100 2 1 1 100 1 1 1 1 1 100 100 100 1 100 100 100 100 2 1 100 100 1 3 100 100 100 100 1 100 100 100 1
result:
ok Correct. (1 test case)
Test #22:
score: 0
Accepted
time: 0ms
memory: 12104kb
input:
2 5 6 100 1 2 1 1 100 1 1 2 100 100 100 1 1 1 100 100 100 2 1 1 100 1 1 1 1 2 100 100 100 1 100 100 100 100 2 1 100 100 1 2 100 100 100 100 1 100 100 100 2 6 5 100 1 100 100 100 100 100 2 1 100 100 2 100 100 2 100 100 1 1 100 100 100 100 100 1 2 1 100 100 100 1 1 1 100 1 1 2 2 2 1 1 100 1 1 1 100 10...
output:
117 1 2 1 8 101 9 1 2 100 100 100 1 83 1 100 100 100 2 1 9 100 9 1 1 2 2 100 100 100 1 100 100 100 100 2 1 100 100 1 4 100 100 100 100 1 100 100 100 2 101 1 100 100 100 100 100 2 5 100 100 2 100 100 2 100 100 3 3 100 100 100 100 100 1 2 1 100 100 100 1 1 1 100 1 1 2 94 2 1 1 100 1 1 1 100 100 100 2 1
result:
ok Correct. (2 test cases)
Test #23:
score: 0
Accepted
time: 4ms
memory: 12028kb
input:
55 6 6 98 396311720 585129723 216006508 789713291 522861691 585129723 216006508 789713291 522861691 174874210 216006508 789713291 522861691 174874210 616414184 789713291 522861691 174874210 616414184 931597164 522861691 174874210 616414184 931597164 831871942 174874210 616414184 931597164 831871942 ...
output:
98 396311720 585129723 216006508 789713291 522861691 585129723 216006508 789713291 522861691 174874308 216006508 789713291 522861691 174874210 616414184 789713291 522861691 174874210 616414184 931597164 522861691 174874210 616414184 931597164 831871942 174874210 616414184 931597164 831871942 1498211...
result:
ok Correct. (55 test cases)
Test #24:
score: 0
Accepted
time: 3ms
memory: 12044kb
input:
55 6 6 96 10384494 17185421 10646458 18552039 13790956 17185421 10646458 18552039 13790956 13642043 10646458 18552039 13790956 13642043 10307995 18552039 13790956 13642043 10307995 14193711 13790956 13642043 10307995 14193711 19297204 13642043 10307995 14193711 19297204 12810329 10384494 17185421 10...
output:
96 10384494 17185421 10646458 18552039 13790956 17185421 10646458 18552039 13790956 13642043 10646458 18552039 13790956 13642043 10308091 18552039 13790956 13642043 10307995 14193711 13790956 13642043 10307995 14193711 19297204 13642043 10307995 14193711 19297204 12810329 10384494 17185421 10646458 ...
result:
ok Correct. (55 test cases)
Test #25:
score: 0
Accepted
time: 7ms
memory: 12044kb
input:
31 8 8 84 615535 844446 885043 54908 235817 174599 782716 844446 885043 54908 235817 174599 782716 140021 885043 54908 235817 174599 782716 140021 505505 54908 235817 174599 782716 140021 505505 551220 235817 174599 782716 140021 505505 551220 980613 174599 782716 140021 505505 551220 980613 844864 ...
output:
84 615535 844446 885043 54908 235817 174599 782800 844446 885043 54908 235817 174599 782716 140021 885043 54908 235817 174599 782716 140021 505505 54908 235817 174599 782716 140021 505505 551220 235817 174599 782716 140021 505505 551220 980613 174599 782716 140021 505505 551220 980613 844864 782716 ...
result:
ok Correct. (31 test cases)
Test #26:
score: 0
Accepted
time: 13ms
memory: 12048kb
input:
24 9 9 80 100 118 196 180 100 110 153 125 118 196 180 100 110 153 125 200 196 180 100 110 153 125 200 139 180 100 110 153 125 200 139 174 100 110 153 125 200 139 174 169 110 153 125 200 139 174 169 163 153 125 200 139 174 169 163 196 125 200 139 174 169 163 196 173 200 139 174 169 163 196 173 167 10...
output:
80 100 118 196 180 100 110 153 205 118 196 180 100 110 153 125 200 196 180 100 110 153 125 200 139 180 100 110 153 125 200 139 174 100 110 153 125 200 139 174 169 110 153 125 200 139 174 169 163 153 125 200 139 174 169 163 196 125 200 139 174 169 163 196 173 200 139 174 169 163 196 173 167 100 118 1...
result:
ok Correct. (24 test cases)
Test #27:
score: 0
Accepted
time: 3ms
memory: 12228kb
input:
20 10 10 91 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000000 90000001 90000000 90000001 ...
output:
895 90000001 90000000 90000001 90000000 90000000 90000001 90000000 90000001 90000092 90000091 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000001 90000000 90000000 90000001 90000000 90000001 90000001 90000001 90000091 90000090 90000000 90000001 90000000 90000001 90000001...
result:
ok Correct. (20 test cases)
Test #28:
score: 0
Accepted
time: 22ms
memory: 12152kb
input:
10 14 14 68 20 22 23 26 23 22 28 30 25 20 29 22 30 22 23 26 23 22 28 30 25 20 29 22 30 26 23 26 23 22 28 30 25 20 29 22 30 26 20 26 23 22 28 30 25 20 29 22 30 26 20 22 23 22 28 30 25 20 29 22 30 26 20 22 21 22 28 30 25 20 29 22 30 26 20 22 21 26 28 30 25 20 29 22 30 26 20 22 21 26 23 30 25 20 29 22 ...
output:
755 20 22 23 26 23 22 28 30 25 20 29 22 78 42 23 26 23 22 28 30 25 20 29 22 30 48 45 26 23 22 28 30 25 22 29 22 30 26 40 46 23 22 28 30 25 20 29 22 30 26 20 47 48 23 28 30 25 24 29 22 30 26 20 22 41 39 28 30 25 20 29 22 30 26 20 22 21 56 58 30 25 20 29 22 30 26 20 22 21 26 39 46 25 22 29 22 30 26 20...
result:
ok Correct. (10 test cases)
Test #29:
score: 0
Accepted
time: 4ms
memory: 12016kb
input:
178 3 3 53 5 2 4 5 4 2 2 5 1 3 3 1 2 2 90 2 1 2 4 4 5 77 2 3 5 5 5 5 5 3 1 4 4 5 5 3 3 5 2 3 5 4 2 4 4 5 2 3 5 2 4 5 3 3 3 57 4 3 5 3 1 1 5 4 2 1 5 4 2 4 54 4 3 4 3 3 4 1 3 3 5 5 4 89 1 2 3 2 3 3 1 5 1 1 5 4 4 4 4 2 5 1 3 1 1 1 1 5 5 4 3 4 5 3 4 3 3 71 2 2 2 4 3 5 2 1 1 3 1 3 2 2 28 4 5 5 3 2 4 67 2...
output:
155 5 54 10 49 13 46 2 5 1 3 3 1 179 91 91 2 4 301 2 3 6 80 5 5 5 76 9 4 4 74 9 8 5 69 2 3 5 4 2 4 4 5 2 3 5 2 4 5 3 160 4 55 8 51 13 46 5 4 2 1 5 4 107 4 3 57 7 3 54 1 3 3 5 432 1 3 91 2 3 90 1 5 89 5 5 85 9 4 82 2 5 1 3 1 1 1 1 5 5 4 3 4 5 3 4 207 2 73 3 72 4 71 2 1 1 3 1 3 55 32 32 5 3 132 2 2 69...
result:
ok Correct. (178 test cases)
Test #30:
score: 0
Accepted
time: 7ms
memory: 12208kb
input:
25 11 14 66 998244354 998244355 998244354 998244353 998244355 998244354 998244355 998244355 998244353 998244354 998244353 998244353 998244355 998244354 998244353 998244353 998244355 998244355 998244353 998244353 998244354 998244353 998244355 998244353 998244355 998244354 998244353 998244354 99824435...
output:
678 998244354 998244355 998244354 998244353 998244355 998244354 998244355 998244355 998244353 998244354 998244353 998244353 998244415 998244414 998244353 998244353 998244355 998244355 998244353 998244353 998244354 998244353 998244355 998244353 998244355 998244357 998244356 998244354 998244354 998244...
result:
ok Correct. (25 test cases)
Test #31:
score: 0
Accepted
time: 12ms
memory: 12152kb
input:
24 6 9 73 78341 926193143 45972 89662 44179 39258 14522 928569793 79027 37377 30172 71689 54024 923464835 924430887 51505 58776 28871 83814 38691 29833 97617 58712 28722 15902 86266 962252400 27827 905696913 918736501 95599 4669 958072131 65347 27295 68035 95757 92683 65837 2171 3624 17191 63486 455...
output:
73 78341 926193143 45972 89662 44179 39258 14522 928569793 79027 37377 30172 71689 54024 923464835 924430887 51505 58776 28871 83814 38691 29833 97617 58712 28722 15902 86266 962252400 27827 905696913 918736501 95599 4669 958072131 65347 27295 68035 95757 92683 65837 2171 3624 17191 63486 45593 3836...
result:
ok Correct. (24 test cases)
Test #32:
score: 0
Accepted
time: 60ms
memory: 12196kb
input:
25 11 9 68 988729312 978893803 906310688 920140739 959394993 998273729 949853986 924816006 990193010 966906539 937746446 937776039 977125396 935068953 909078120 915698548 43064 967374842 961307275 996408546 925562822 931560002 944384977 981282702 922700388 966488914 982858666 953842932 971076445 992...
output:
68 988729312 978893803 906310688 920140739 959394993 998273729 949853986 924816006 990193010 966906539 937746446 937776039 977125396 935068953 909078120 915698548 43064 967374842 961307275 996408546 925562822 931560002 944384977 981282702 922700388 966488914 982858666 953842932 971076445 992872616 9...
result:
ok Correct. (25 test cases)
Test #33:
score: 0
Accepted
time: 666ms
memory: 12176kb
input:
10 10 50 100 260372550 224370653 929271301 767967410 502284101 349384009 202940941 154783885 145644362 966077435 743845691 149769897 507435023 60468873 659673803 389434862 715266673 14605135 188587870 63000907 442355443 785843949 982378871 22199344 584430140 772755653 965473791 989314835 231680916 9...
output:
100 260372550 224370653 929271301 767967410 502284101 349384009 202940941 154783885 145644362 966077435 743845691 149769897 507435023 60468873 659673803 389434862 715266673 14605135 188587870 63000907 442355443 785843949 982378871 22199344 584430140 772755653 965473791 989314835 231680916 945511294 ...
result:
ok Correct. (10 test cases)
Test #34:
score: 0
Accepted
time: 264ms
memory: 12224kb
input:
10 50 10 100 423572185 145436731 764686000 600633655 441415910 169443508 700789417 229288916 127363250 639533552 227845034 620956056 445675721 622306776 556528832 409465277 277492953 36493847 435349083 314519935 612191794 418296475 601945295 813525152 956721741 827242520 676200660 129973732 11311289...
output:
100 423572185 145436731 764686000 600633655 441415910 169443508 700789417 229288916 127363250 639533552 227845034 620956056 445675721 622306776 556528832 409465277 277492953 36493847 435349083 314519935 612191794 418296475 601945295 813525152 956721741 827242520 676200660 129973732 113112898 8339529...
result:
ok Correct. (10 test cases)
Test #35:
score: 0
Accepted
time: 645ms
memory: 12128kb
input:
10 20 25 100 236319064 155794674 339813709 886024917 794289478 901052716 226506117 8788803 911893440 697579614 51349234 667886501 828088943 787487581 742960185 628606808 506112146 537589422 500076754 950636717 5354362 9412365 605409672 56983400 385937164 675984872 539434747 948264769 790467650 43340...
output:
100 236319064 155794674 339813709 886024917 794289478 901052716 226506117 8788803 911893440 697579614 51349234 667886501 828088943 787487581 742960185 628606808 506112146 537589422 500076754 950636717 5354362 9412365 605409672 56983500 385937164 675984872 539434747 948264769 790467650 433400290 8399...
result:
ok Correct. (10 test cases)
Test #36:
score: 0
Accepted
time: 486ms
memory: 12156kb
input:
10 25 20 100 90000254 90000042 90000073 90000730 90000827 90000755 90000252 90000268 90000739 90000086 90000095 90000941 90000949 90000931 90000696 90000502 90000250 90000492 90000583 90000647 90000476 90000372 90000296 90000374 90000595 90000720 90000922 90000985 90000474 90000983 90000381 90000961...
output:
100 90000254 90000042 90000073 90000730 90000827 90000755 90000252 90000268 90000739 90000086 90000095 90000941 90000949 90000931 90000696 90000502 90000250 90000492 90000583 90000647 90000476 90000372 90000296 90000374 90000595 90000720 90000922 90000985 90000474 90000983 90000381 90000961 90000417...
result:
ok Correct. (10 test cases)
Test #37:
score: 0
Accepted
time: 198ms
memory: 12168kb
input:
10 10 50 100 10000 10000 10000 10000 10003 10001 10005 10001 10003 10000 10005 10000 10002 10001 10005 10001 10000 10000 10003 10005 10001 10005 10004 10000 10003 10000 10005 10001 10002 10000 10002 10005 10002 10000 10005 10003 10002 10003 10001 10001 10003 10002 10004 10003 10000 10004 10003 10000...
output:
833 10000 10000 10000 10000 10003 10001 10005 10001 10003 10000 10005 10000 10002 10001 10005 10001 10000 10000 10003 10005 10001 10005 10004 10000 10003 10000 10005 10001 10002 10000 10002 10005 10002 10000 10005 10003 10002 10003 10001 10001 10003 10002 10004 10003 10000 10004 10003 10000 10100 10...
result:
ok Correct. (10 test cases)
Test #38:
score: 0
Accepted
time: 49ms
memory: 10168kb
input:
12 20 20 100 2 1 2 4 3 4 3 5 4 3 5 5 2 1 1 4 3 1 4 1 4 3 2 2 3 3 4 2 5 4 1 1 1 3 3 2 3 1 2 2 1 4 5 3 1 1 1 1 2 3 3 2 2 3 2 4 2 3 2 2 4 5 3 4 2 1 5 5 3 4 1 5 1 3 4 3 1 2 2 2 4 4 5 2 2 5 5 3 1 1 2 5 3 1 2 2 3 2 4 5 3 4 1 2 1 1 4 2 5 1 1 4 2 3 1 3 4 5 5 2 3 4 4 4 5 2 4 5 3 5 4 2 5 5 5 1 2 5 5 1 3 5 4 5...
output:
1637 2 2 2 4 3 4 3 6 4 3 5 5 2 1 1 4 3 2 82 1 4 4 4 2 4 4 4 3 5 4 5 2 1 3 3 2 3 80 4 2 2 4 5 3 4 5 1 3 6 4 3 3 3 3 3 5 75 5 2 3 4 5 3 4 2 1 5 7 3 4 2 5 2 3 4 74 5 2 3 2 6 4 5 2 2 5 5 4 1 5 4 5 3 3 72 4 3 5 4 5 4 4 2 2 4 4 4 2 5 5 6 4 2 69 3 5 4 5 5 2 3 4 4 4 5 2 4 6 3 8 4 2 65 5 5 4 2 5 5 3 3 5 4 5 ...
result:
ok Correct. (12 test cases)
Extra Test:
score: 0
Extra Test Passed