QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#291064 | #4323. 德州消消乐 | MoRanSky | AC ✓ | 16ms | 4156kb | C++23 | 8.2kb | 2023-12-26 04:41:30 | 2023-12-26 04:41:30 |
Judging History
answer
// Skyqwq
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair<int, int> PII;
typedef long long LL;
template <typename T> bool chkMax(T &x, T y) { return (y > x) ? x = y, 1 : 0; }
template <typename T> bool chkMin(T &x, T y) { return (y < x) ? x = y, 1 : 0; }
template <typename T> void inline read(T &x) {
int f = 1; x = 0; char s = getchar();
while (s < '0' || s > '9') { if (s == '-') f = -1; s = getchar(); }
while (s <= '9' && s >= '0') x = x * 10 + (s ^ 48), s = getchar();
x *= f;
}
const int N = 55, S = 105, Q = 1005;
int n, m, K, q, cnt;
struct E{
int a, b;
} e[N][N];
LL ans = 0;
int f[N * N], sz[N * N];
int inline id(int x, int y) {
return (x - 1) * m + y;
}
int find(int x) {
return x == f[x] ? x : f[x] = find(f[x]);
}
void inline merge(int x, int y) {
x = find(x), y = find(y);
if (x == y) return;
if (sz[x] > sz[y]) swap(x, y);
f[x] = y, sz[y] += sz[x];
}
vector<int> mc;
bool st[S];
void inline init() {
for (int i = 1; i <= n * m; i++) f[i] = i, sz[i] = 1;
for (int i = 1; i <= K; i++) st[i] = 0;
}
bool ok = 0;
int inline olg() {
init();
mc.clear();
int sum = 0; ok = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (!e[i][j].a) continue;
if (i == 1 || (i > 1 && e[i - 1][j].a != e[i][j].a)) {
int k = i;
while (k < n && e[k + 1][j].a == e[i][j].a) k++;
if (k - i + 1 >= 3) {
ok = 1;
int co = e[i][j].a;
if (!st[co]) st[co] = 1, mc.pb(co);
for (int u = i + 1; u <= k; u++)
merge(id(u, j), id(i, j));
}
}
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (!e[i][j].a) continue;
if (j == 1 || (j > 1 && e[i][j - 1].a != e[i][j].a)) {
int k = j;
while (k < m && e[i][k + 1].a == e[i][j].a) k++;
if (k - j + 1 >= 3) {
int co = e[i][j].a;
ok = 1;
if (!st[co]) st[co] = 1, mc.pb(co);
for (int u = j + 1; u <= k; u++)
merge(id(i, u), id(i, j));
}
}
}
}
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
if (i < n && e[i][j].a == e[i + 1][j].a && sz[find(id(i, j))] > 1 && sz[find(id(i + 1, j))] > 1)
merge(id(i, j), id(i + 1, j));
if (j < m && e[i][j].a == e[i][j + 1].a && sz[find(id(i, j))] > 1 && sz[find(id(i, j + 1))] > 1)
merge(id(i, j), id(i, j + 1));
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
int u = id(i, j);
if (find(u) == u && sz[u] > 1) {
sum += (sz[u] - 3) * (sz[u] - 3) * 50;
}
}
}
return sum;
}
vector<vector<int> > z;
bool de[N][N];
void inline del(int x, int y) {
if (x < 1 || x > n || y < 1 || y > m) return;
if (!e[x][y].a) return;
if (de[x][y]) return;
de[x][y] = 1;
ans += cnt * e[x][y].a;
if (e[x][y].b) {
int tp = e[x][y].b;
//cout << x << " " << y << " st to " << tp << endl;
if (tp == 1) {
for (int j = 1; j <= m; j++)
del(x, j);
} else if (tp == 2) {
for (int i = 1; i <= n; i++)
del(i, y);
} else if (tp == 3) {
for (int j = 1; j <= m; j++)
del(x, j);
for (int i = 1; i <= n; i++)
del(i, y);
} else if (tp == 4) {
for (int i = -1; i <= 1; i++)
for (int j = -1; j <= 1; j++)
del(x + i, y + j);
} else if (tp == 5) {
for (int i = -2; i <= 2; i++)
for (int j = -2; j <= 2; j++)
del(x + i, y + j);
} else {
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
if (e[i][j].a == e[x][y].a) del(i, j);
}
}
e[x][y].a = e[x][y].b = 0;
}
void inline down() {
for (int j = 1; j <= m; j++) {
int R = n;
for (int i = n; i; i--) {
if (e[i][j].a) {
e[R--][j] = e[i][j];
}
}
for (int i = 1; i <= R; i++) e[i][j].a = e[i][j].b = 0;
}
}
void inline work() {
memset(de, 0, sizeof de);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (sz[find(id(i, j))] > 1)
del(i, j);
}
}
down();
}
int mx = 0;
int inline gaopai(vector<int> w) {
for (int i = 0; i + 1 < w.size(); i++)
if (w[i] == w[i + 1]) return -1;
int s = 50;
assert(w.size() == 5);
s += w[4];
return s;
}
int inline yidui(vector<int> w) {
int num = 0, bh = 0;
for (int i = 0; i + 1 < w.size(); i++)
if (w[i] == w[i + 1]) {
num++;
bh = w[i];
}
if (num != 1) {
return -1;
}
int s = 100 + bh * 2;
return s;
}
int inline liangdui(vector<int> w) {
int num = 0, bh = 0;
vector<int> o;
for (int i = 0; i + 1 < w.size(); i++) {
if (w[i] == w[i + 1]) {
num++;
o.pb(w[i]);
if (i + 2 < w.size() && w[i + 1] == w[i + 2]) {
return -1;
}
}
}
if (num != 2) {
return -1;
}
int s = 200 + o[1] * 2 + o[0];
return s;
}
int inline santiao(vector<int> w) {
int num = 0, bh = 0;
for (int i = 0; i + 1 < w.size(); i++) {
if (w[i] == w[i + 1]) {
num++;
if (i + 2 < w.size() && w[i + 1] == w[i + 2]) {
bh = w[i];
}
}
}
if (num != 2 || !bh) {
return -1;
}
int s = 300 + bh * 3;
return s;
}
int inline hulu(vector<int> w) {
int num = 0, bh = 0;
for (int i = 0; i + 1 < w.size(); i++) {
if (w[i] == w[i + 1]) {
num++;
if (i + 3 < w.size() && w[i + 1] == w[i + 2]&& w[i + 2] == w[i + 3]) {
return -1;
}
if (i + 2 < w.size() && w[i + 1] == w[i + 2]) {
bh = w[i];
}
}
}
int p = 0;
while (p < 5 && w[p] == bh) p++;
if (num != 3 || !bh || p == 5) {
return -1;
}
int s = 500 + bh * 3 + w[p];
return s;
}
int inline sitiao(vector<int> w) {
int num = 0, bh = 0;
for (int i = 0; i + 1 < w.size(); i++) {
if (w[i] == w[i + 1]) {
num++;
if (i + 3 < w.size() && w[i + 1] == w[i + 2]&& w[i + 2] == w[i + 3]) {
bh = w[i];
}
}
}
if (num != 3 || !bh) {
return -1;
}
int s = 750 + bh * 5;
return s;
}
int inline wutiao(vector<int> w) {
int num = 0, bh = 0;
for (int i = 0; i + 1 < w.size(); i++) {
if (w[i] == w[i + 1]) {
num++;
}
}
if (num != 4) {
return -1;
}
int s = 1000 + w[0] * 10;
return s;
}
int calc(vector<int> w) {
sort(w.begin(), w.end());
int w1 = gaopai(w);
if (w1 != -1) {
return w1;
}
w1 = yidui(w);
if (w1 != -1) {
return w1;
}
w1 = liangdui(w);
if (w1 != -1) {
return w1;
}
w1 = santiao(w);
if (w1 != -1) {
return w1;
}
w1 = wutiao(w);
if (w1 != -1) {
return w1;
}
w1 = sitiao(w);
if (w1 != -1) {
return w1;
}
w1 = hulu(w);
if (w1 != -1) {
return w1;
}
assert(false);
}
void dfs(int u, vector<int> now) {
if (u == z.size()) {
chkMax(mx, calc(now));
return;
}
for (int v: z[u]) {
now.pb(v);
dfs(u + 1, now);
now.pop_back();
}
}
void inline red() {
mx = -2e9;
vector<int> now;
dfs(0, now);
//cout << mx << " jf\n";
ans += mx;
z.clear();
}
int main() {
read(n), read(m); read(K), read(q);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) read(e[i][j].a);
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) read(e[i][j].b);
int yx = 0;
for (int i = 1; i <= q; i++) {
int x1, y1, x2, y2; read(x1), read(y1), read(x2), read(y2);
if (abs(x1 - x2) + abs(y1 - y2) != 1) continue;
if (!e[x1][y1].a || !e[x2][y2].a) continue;
swap(e[x1][y1], e[x2][y2]);
int w = olg();
int la = ans;
if (ok) {
++yx;
cnt = 0;
z.pb(mc);
int sumC = 0;
while (1) {
w = olg();
if (!ok) break;
//cout << w << "madan\n";
ans += w;
++cnt;
work();
sumC++;
// cout << "-=--=-=" << cnt << endl;
// for (int i = 1; i <= n; i++) {
// for (int j = 1; j <= m; j++) {
// cout << e[i][j].a << " ";
// }
// cout << endl;
// }
// puts("---");
}
ans += (sumC - 1) * (sumC - 1) * 80;
} else {
swap(e[x1][y1], e[x2][y2]);
}
//cout << i << "->>>" << ans - la << endl;
if (z.size() == 5) red();
}
if (yx == q) ans += 1000;
int num = 0;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) if (e[i][j].a) num++;
if (!num) ans += 10000;
printf("%lld\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
8 8 5 5 1 1 5 1 5 4 5 3 2 1 2 2 5 4 3 2 1 4 1 4 2 1 5 4 2 1 5 5 2 1 4 4 2 3 5 2 3 4 2 2 4 2 4 3 3 2 4 5 1 3 4 3 5 2 4 3 3 4 2 5 2 1 1 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 3 1 0 0 0 0 3 0 0 0 0 0 0 0 0 0 1 4 3 2 4 2 5 4 5 5 7 2 7 3 8 5 8 6 6 7 ...
output:
11692
result:
ok single line: '11692'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
10 10 2 1 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 2 1 2 1 2 1 2 1 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
output:
108124
result:
ok single line: '108124'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
50 50 2 1 2 1 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 1 2 2 ...
output:
138130775
result:
ok single line: '138130775'
Test #4:
score: 0
Accepted
time: 13ms
memory: 3844kb
input:
49 50 65 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 2 4 5 ...
output:
91395346
result:
ok single line: '91395346'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
50 50 100 1 1 1 89 1 11 35 63 13 23 74 44 29 13 2 41 11 49 14 5 22 37 82 95 62 8 75 52 28 28 32 54 48 4 12 52 78 79 9 9 46 34 65 42 38 80 48 59 37 20 94 51 92 25 46 87 26 3 19 65 42 50 72 63 19 40 1 61 35 99 13 40 83 48 13 93 56 90 29 23 15 39 68 17 63 37 50 55 32 20 86 62 92 61 61 48 28 20 20 18 52...
output:
25471
result:
ok single line: '25471'
Test #6:
score: 0
Accepted
time: 1ms
memory: 3868kb
input:
49 50 65 1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 1 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 2 4 5 ...
output:
733763
result:
ok single line: '733763'
Test #7:
score: 0
Accepted
time: 1ms
memory: 4144kb
input:
50 50 9 1 1 1 4 1 8 5 5 3 7 6 6 8 9 2 8 4 7 1 5 4 9 9 8 6 7 6 3 7 6 7 4 2 7 7 2 6 2 7 5 5 8 4 9 7 8 8 5 1 6 3 9 9 5 8 7 6 5 5 3 3 8 1 4 2 7 6 6 1 5 8 9 1 7 8 2 9 1 6 7 7 4 7 2 5 2 6 5 4 4 9 7 7 8 5 2 2 1 1 4 3 4 5 2 4 1 2 1 8 3 6 6 3 3 5 5 4 5 6 6 2 6 1 5 8 2 2 9 4 6 5 8 2 2 3 1 1 8 9 2 2 7 8 3 9 4 ...
output:
4472
result:
ok single line: '4472'
Test #8:
score: 0
Accepted
time: 1ms
memory: 4156kb
input:
50 50 9 1 1 1 3 1 3 8 8 1 2 1 7 7 5 5 9 1 7 6 2 7 1 9 8 5 4 8 3 4 8 9 3 7 7 3 9 2 8 9 8 7 6 2 7 4 9 9 7 2 8 5 6 6 8 7 7 2 5 6 4 8 4 8 6 1 1 6 4 4 5 5 4 7 6 2 2 1 7 2 3 1 2 6 2 1 9 2 2 7 9 7 5 6 7 9 8 7 7 3 6 7 8 9 5 7 7 8 9 1 5 8 3 9 4 6 1 6 8 4 5 1 9 3 8 3 3 5 9 4 4 3 7 9 5 8 8 7 5 2 3 9 2 7 6 2 6 ...
output:
10659
result:
ok single line: '10659'
Test #9:
score: 0
Accepted
time: 16ms
memory: 3864kb
input:
50 48 100 1000 17 96 31 100 66 100 26 97 28 97 13 97 65 95 31 95 6 95 26 99 90 96 37 96 73 97 46 97 80 97 44 100 63 98 25 98 10 97 54 98 70 98 74 98 64 98 55 98 96 62 96 70 100 4 97 54 97 36 97 82 95 23 95 34 95 90 99 32 99 67 96 7 97 11 97 4 97 94 100 26 100 2 98 79 97 42 97 64 98 73 98 14 98 68 98...
output:
104407
result:
ok single line: '104407'
Test #10:
score: 0
Accepted
time: 9ms
memory: 3836kb
input:
50 48 100 1000 60 97 29 99 37 99 62 97 73 100 63 100 23 98 26 97 83 97 84 100 50 99 49 99 55 96 94 97 64 97 82 98 83 99 69 99 12 96 42 98 50 98 30 96 21 99 41 99 97 37 97 12 99 70 97 85 97 50 100 41 98 40 98 26 97 43 100 19 100 7 99 26 96 2 96 11 97 83 98 63 98 23 99 42 96 57 96 55 98 44 96 32 96 92...
output:
102025
result:
ok single line: '102025'
Test #11:
score: 0
Accepted
time: 13ms
memory: 3804kb
input:
50 48 22 300 2 6 2 21 17 13 17 21 20 10 20 21 11 20 11 21 18 5 18 21 10 1 10 21 8 19 8 21 9 8 9 21 13 14 13 21 10 2 10 21 3 1 3 21 6 14 6 21 6 2 6 22 13 17 13 22 10 20 10 22 20 11 20 22 5 18 5 22 1 10 1 22 19 8 19 22 8 9 8 22 14 13 14 22 2 10 2 22 1 3 1 22 14 6 14 22 8 1 8 21 7 18 7 21 19 3 19 21 16...
output:
30201
result:
ok single line: '30201'
Test #12:
score: 0
Accepted
time: 0ms
memory: 3988kb
input:
8 8 5 8 1 1 5 1 5 4 5 3 2 1 2 2 5 4 3 2 1 4 1 4 2 1 5 4 2 1 5 5 2 1 4 4 2 3 5 2 3 4 2 2 4 2 4 3 3 2 4 5 1 3 4 3 5 2 4 3 3 4 2 5 2 1 1 2 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 3 1 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 1 1 2 2 3 2 4 2 3 2 3 3 4 2 4 3 5 4 ...
output:
684
result:
ok single line: '684'
Test #13:
score: 0
Accepted
time: 12ms
memory: 3800kb
input:
50 48 8 300 1 4 1 7 3 1 3 7 5 6 5 7 2 4 2 7 6 5 6 7 2 6 2 7 4 3 4 7 2 3 2 7 1 2 1 7 6 5 6 7 6 4 6 7 3 5 3 7 4 1 4 8 1 3 1 8 6 5 6 8 4 2 4 8 5 6 5 8 6 2 6 8 3 4 3 8 3 2 3 8 2 1 2 8 5 6 5 8 4 6 4 8 5 3 5 8 3 4 3 7 1 6 1 7 2 5 2 7 1 4 1 7 4 3 4 7 1 3 1 7 4 1 4 7 4 2 4 7 6 2 6 7 4 2 4 7 2 6 2 7 1 2 1 7 ...
output:
38025
result:
ok single line: '38025'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
10 10 5 10 5 2 2 1 2 5 2 1 4 2 5 1 4 1 4 3 1 2 3 5 2 2 3 2 2 4 5 5 1 3 5 4 1 3 5 2 5 3 2 2 3 1 5 5 1 3 3 1 3 1 5 2 3 1 1 3 5 5 2 2 1 2 4 3 5 2 4 2 1 4 3 3 1 5 3 3 2 4 3 1 4 3 4 3 5 2 4 4 3 4 5 1 1 2 1 4 5 3 5 4 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6...
output:
2829
result:
ok single line: '2829'
Test #15:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
10 10 5 10 2 1 4 5 3 1 3 3 5 5 1 2 2 1 1 4 5 5 2 5 2 2 3 4 3 1 4 5 5 3 5 1 4 2 3 1 1 3 1 1 4 5 1 2 2 5 5 4 1 2 5 1 4 3 3 5 1 3 5 3 2 1 1 4 2 3 5 2 4 5 2 5 3 2 4 5 5 1 1 3 1 5 4 2 4 1 3 3 2 5 5 3 2 5 5 3 5 4 5 5 0 0 4 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0...
output:
3496
result:
ok single line: '3496'
Test #16:
score: 0
Accepted
time: 10ms
memory: 4072kb
input:
50 50 5 1000 2 4 5 4 5 1 3 4 4 5 2 3 5 4 1 2 3 4 4 5 5 1 5 4 1 4 3 3 5 2 1 4 4 2 4 1 3 5 5 3 5 4 1 4 4 2 1 5 5 3 2 2 1 2 3 3 1 4 5 1 5 5 4 3 5 5 4 3 4 2 3 5 4 4 5 1 5 2 5 5 2 5 3 2 1 3 3 2 5 3 4 4 5 5 2 3 3 1 5 5 4 3 4 5 4 5 5 2 2 4 5 1 4 1 4 1 3 2 5 4 2 1 5 5 4 1 1 2 2 5 1 5 3 4 4 5 5 4 4 5 1 3 3 5...
output:
75165
result:
ok single line: '75165'
Test #17:
score: 0
Accepted
time: 14ms
memory: 3868kb
input:
50 50 5 1000 5 4 1 1 4 2 1 3 2 3 4 2 4 3 1 5 4 5 1 5 5 2 5 1 3 4 2 2 1 2 4 5 5 2 5 2 5 1 2 3 5 4 2 3 2 4 2 5 3 3 5 4 5 1 1 2 4 1 4 2 4 2 1 3 3 4 4 3 3 5 3 2 5 4 1 5 4 1 4 1 2 3 1 2 5 1 1 3 2 2 5 3 4 1 5 1 5 1 5 1 4 1 5 5 2 5 3 2 4 3 1 3 5 1 2 1 1 2 4 2 4 3 1 1 5 4 4 2 1 4 4 2 1 4 1 4 1 5 5 3 1 3 3 5...
output:
64620
result:
ok single line: '64620'
Test #18:
score: 0
Accepted
time: 4ms
memory: 4144kb
input:
50 50 5 1000 1 5 4 2 5 4 4 3 1 1 3 3 2 2 5 3 1 5 1 5 5 1 2 5 1 3 1 5 2 2 5 3 2 5 1 5 2 5 1 5 5 4 5 1 5 1 3 1 4 5 1 5 5 3 3 4 5 1 3 1 1 4 4 2 2 1 3 4 2 5 4 5 1 4 4 2 3 2 3 1 1 4 2 2 3 1 2 1 2 3 4 2 4 5 4 3 3 5 3 5 2 4 2 1 4 2 1 2 1 2 2 4 4 5 4 4 2 2 4 1 5 3 2 5 1 4 3 5 3 2 2 3 1 5 5 1 3 5 3 5 5 4 3 3...
output:
137846
result:
ok single line: '137846'
Test #19:
score: 0
Accepted
time: 14ms
memory: 3804kb
input:
50 50 9 1000 7 7 6 5 3 7 7 4 8 2 4 6 8 9 6 9 7 7 2 1 4 3 1 7 9 7 7 8 4 2 2 4 3 3 2 6 2 7 8 7 7 1 9 2 2 5 6 3 4 3 5 3 1 3 9 1 6 1 3 1 2 7 5 7 4 2 2 7 4 2 9 7 7 1 9 8 1 8 7 5 5 8 5 3 5 6 2 1 4 9 8 6 4 1 3 3 6 8 1 2 9 2 7 7 6 8 8 9 3 4 3 2 7 9 2 5 6 8 9 3 9 3 5 6 5 8 7 5 1 4 8 9 3 1 7 9 9 2 9 2 6 4 1 9...
output:
27710
result:
ok single line: '27710'
Test #20:
score: 0
Accepted
time: 14ms
memory: 4080kb
input:
50 50 9 1000 8 3 9 2 6 1 4 5 8 2 8 9 5 9 6 6 8 2 7 5 8 4 7 6 2 6 8 4 9 1 2 1 1 7 2 8 5 8 7 4 7 7 1 8 1 2 8 6 6 9 2 4 9 2 1 8 1 7 1 1 3 7 1 3 5 3 9 4 5 1 6 7 7 1 8 1 7 5 9 9 2 4 6 6 9 6 1 1 7 9 4 8 4 5 9 4 4 3 8 1 9 1 2 4 3 1 1 9 1 5 2 3 2 5 9 7 7 4 2 3 9 5 3 7 5 7 7 1 5 6 6 4 1 4 9 1 2 8 5 7 2 9 3 7...
output:
29443
result:
ok single line: '29443'
Test #21:
score: 0
Accepted
time: 13ms
memory: 3788kb
input:
50 50 20 1000 19 1 8 13 16 3 13 11 17 11 13 8 17 2 12 8 4 2 9 17 1 14 19 19 3 12 4 12 11 6 15 2 13 5 14 12 15 5 3 2 17 10 15 20 8 10 16 5 9 17 9 9 17 20 16 16 3 1 16 15 19 16 14 11 10 5 12 11 6 10 4 7 5 13 19 14 14 6 1 7 11 16 12 20 17 5 11 15 7 10 15 5 12 11 7 10 15 5 12 17 3 16 16 12 18 17 11 15 7...
output:
1515
result:
ok single line: '1515'
Test #22:
score: 0
Accepted
time: 9ms
memory: 3796kb
input:
50 50 25 1000 24 16 4 3 12 8 6 6 2 25 18 20 9 8 22 7 25 7 17 1 14 15 6 8 19 16 10 14 4 10 10 16 9 23 10 25 16 20 19 1 1 17 16 9 5 19 9 10 6 5 6 16 4 3 9 16 8 2 24 15 19 11 2 18 8 25 9 3 16 25 7 4 24 11 12 8 14 23 17 8 19 24 16 7 16 12 3 9 2 5 7 19 25 20 19 18 11 12 8 18 24 24 5 20 1 25 24 7 23 8 4 5...
output:
580
result:
ok single line: '580'
Test #23:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
2 3 2 1 1 1 2 2 2 1 0 0 0 0 0 0 1 3 2 3
output:
11009
result:
ok single line: '11009'
Test #24:
score: 0
Accepted
time: 13ms
memory: 4076kb
input:
50 50 100 1000 67 90 89 3 5 74 17 86 71 69 54 94 80 33 58 45 42 20 96 98 14 83 61 15 65 13 15 46 43 82 33 4 58 17 87 91 53 75 40 52 54 26 39 21 49 9 92 63 67 88 31 64 33 70 86 46 20 61 37 78 54 18 93 38 58 51 59 3 85 14 71 15 46 37 46 8 62 65 4 89 5 95 84 67 66 68 65 30 63 86 7 27 43 59 14 73 29 81 ...
output:
276
result:
ok single line: '276'
Test #25:
score: 0
Accepted
time: 1ms
memory: 4044kb
input:
2 3 2 2 1 1 2 2 2 1 0 0 0 0 0 0 1 1 2 1 1 3 2 3
output:
10009
result:
ok single line: '10009'
Test #26:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 4 2 1 1 1 2 2 2 2 1 2 0 0 0 0 0 0 0 0 1 3 2 3
output:
1061
result:
ok single line: '1061'
Test #27:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
2 5 3 2 2 1 2 3 3 2 2 3 1 1 0 0 2 0 0 0 0 0 0 0 1 2 2 2 2 2 2 3
output:
9
result:
ok single line: '9'
Test #28:
score: 0
Accepted
time: 0ms
memory: 4104kb
input:
2 4 2 5 1 1 2 2 2 2 1 1 0 0 0 0 0 0 0 0 1 1 2 1 2 2 2 2 1 4 2 3 1 1 1 4 1 1 1 2
output:
0
result:
ok single line: '0'
Test #29:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
5 5 2 1 1 1 2 1 1 1 1 2 1 1 2 2 1 2 2 1 1 2 1 1 1 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 3 4 3
output:
3023
result:
ok single line: '3023'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
5 5 2 1 1 1 2 1 1 1 1 2 1 1 2 2 1 2 2 1 1 2 1 1 1 1 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 3 3 4 3
output:
12033
result:
ok single line: '12033'