QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#869618 | #2735. Shifty Grid | hhoppitree | 25 ✓ | 118ms | 4456kb | C++17 | 2.5kb | 2025-01-25 12:08:36 | 2025-01-25 12:08:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, a[N][N], b[N];
vector< array<int, 3> > res;
void opt(int dir, int x, int y) {
if (dir == 1) {
y = (y % m + m) % m;
res.push_back({dir, x, y});
for (int i = 0; i < m; ++i) b[(i + y) % m] = a[x][i];
for (int i = 0; i < m; ++i) a[x][i] = b[i];
} else {
y = (y % n + n) % n;
res.push_back({dir, x, y});
for (int i = 0; i < n; ++i) b[(i + y) % n] = a[i][x];
for (int i = 0; i < n; ++i) a[i][x] = b[i];
}
}
int solve() {
for (int i = 0; i + 1 < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] == i * m + j) continue;
for (int k = j + 1; k < m; ++k) {
if (a[i][k] == i * m + j) opt(2, k, 1), opt(1, i + 1, (k == j + 1 ? 1 : -1)), opt(2, k, -1);
}
for (int k = i + 1; k < n; ++k) {
if (a[k][j] == i * m + j) opt(1, k, 1);
}
for (int k = i + 1; k < n; ++k) {
for (int l = 0; l < m; ++l) {
if (a[k][l] != i * m + j) continue;
opt(2, j, k - i), opt(1, k, j - l), opt(2, j, i - k);
break;
}
}
}
}
int D = 1;
for (int i = 0; i < m; ++i) {
if (a[n - 1][i] == (n - 1) * m + i) continue;
for (int j = i + 1; j < m; ++j) {
if (a[n - 1][j] != (n - 1) * m + i) continue;
opt(1, n - 1, m - 1 - j), opt(2, m - 1, D), opt(1, n - 1, j - i), opt(2, m - 1, -D);
opt(1, n - 1, m - (j - i)), opt(2, m - 1, D), opt(1, n - 1, j + 1);
D = -D;
break;
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] != i * m + j) return 0;
}
}
printf("%d\n", (int)res.size());
for (auto [x, y, z] : res) printf("%d %d %d\n", x, y + 1, z);
return 1;
}
int back[N][N];
signed main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) scanf("%d", &back[i][j]);
}
mt19937 rnd;
while (1) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) a[i][j] = back[i][j];
}
res.clear();
for (int i = 0; i < n; ++i) opt(1, i, rnd() % m);
for (int i = 0; i < m; ++i) opt(2, i, rnd() % n);
if (solve()) return 0;
}
return 0;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
2 2 0 1 2 3
output:
15 1 1 0 1 2 0 2 1 0 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1 1 2 0 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1 1 2 0
result:
ok
Test #2:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
4 2 5 2 1 3 6 4 0 7
output:
34 1 1 1 1 2 0 1 3 0 1 4 1 2 1 0 2 2 2 2 1 1 1 2 1 2 1 3 2 2 1 1 2 1 2 2 3 2 2 1 1 3 1 2 2 3 1 3 1 2 1 1 1 3 1 2 1 3 1 4 1 2 2 2 1 4 1 2 2 2 2 2 1 1 4 1 2 2 3 1 4 1 2 1 1 1 4 1 2 1 3 1 4 1 2 2 1 1 4 1 2 2 3
result:
ok
Test #3:
score: 5
Accepted
time: 1ms
memory: 3840kb
input:
4 2 0 2 6 4 7 5 3 1
output:
22 1 1 1 1 2 1 1 3 0 1 4 1 2 1 3 2 2 1 2 1 1 1 2 1 2 1 3 2 2 2 1 3 1 2 2 2 1 4 1 2 1 2 1 4 1 2 1 2 2 2 1 1 3 1 2 2 3 2 2 1 1 4 1 2 2 3
result:
ok
Test #4:
score: 5
Accepted
time: 1ms
memory: 3840kb
input:
4 2 3 6 4 5 7 1 2 0
output:
25 1 1 0 1 2 0 1 3 0 1 4 1 2 1 0 2 2 3 1 4 1 2 1 3 1 4 1 2 1 1 1 2 1 2 2 1 1 2 1 2 2 3 2 1 1 1 3 1 2 1 3 1 4 1 2 2 2 1 4 1 2 2 2 1 4 1 2 1 1 1 4 1 2 1 3
result:
ok
Test #5:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
4 2 5 2 0 1 7 3 4 6
output:
24 1 1 0 1 2 0 1 3 0 1 4 1 2 1 0 2 2 3 1 2 1 2 1 1 1 2 1 2 1 3 2 1 2 1 4 1 2 1 2 1 4 1 2 2 2 1 4 1 2 2 2 2 2 1 1 4 1 2 2 3 1 4 1 2 1 1 1 4 1 2 1 3
result:
ok
Test #6:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
4 2 6 1 0 5 3 4 2 7
output:
23 1 1 1 1 2 1 1 3 0 1 4 1 2 1 3 2 2 1 2 1 2 1 3 1 2 1 2 2 2 3 1 4 1 2 2 1 1 4 1 2 1 2 1 4 1 2 1 2 1 4 1 2 2 2 1 4 1 2 2 2 2 1 1 1 4 1 2 1 3
result:
ok
Test #7:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
2 4 6 4 5 3 1 7 0 2
output:
40 1 1 0 1 2 2 2 1 0 2 2 1 2 3 0 2 4 1 1 2 1 2 1 1 1 2 3 2 1 1 2 2 1 1 2 3 2 2 1 2 3 1 1 2 2 2 3 1 2 4 1 1 2 2 2 4 1 1 2 0 2 4 1 1 2 3 2 4 1 1 2 1 2 4 1 1 2 0 1 2 1 2 4 1 1 2 1 2 4 1 1 2 3 2 4 1 1 2 3 1 2 0 2 4 1 1 2 1 2 4 1 1 2 3 2 4 1 1 2 0
result:
ok
Test #8:
score: 5
Accepted
time: 1ms
memory: 3840kb
input:
2 2 0 1 3 2
output:
8 1 1 0 1 2 0 2 1 0 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1
result:
ok
Test #9:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
2 4 1 5 3 0 7 4 6 2
output:
33 1 1 0 1 2 2 2 1 0 2 2 1 2 3 0 2 4 1 2 1 1 1 2 1 2 1 1 1 2 1 2 2 1 1 2 3 2 2 1 2 3 1 1 2 2 2 3 1 2 4 1 1 2 3 2 4 1 1 2 1 2 4 1 1 2 2 2 4 1 1 2 2 2 4 1 1 2 3 1 2 0 2 4 1 1 2 1 2 4 1 1 2 3 2 4 1 1 2 0
result:
ok
Test #10:
score: 5
Accepted
time: 0ms
memory: 3840kb
input:
2 2 3 2 0 1
output:
8 1 1 0 1 2 0 2 1 0 2 2 1 1 2 1 2 1 1 1 2 1 2 1 1
result:
ok
Subtask #2:
score: 10
Accepted
Test #11:
score: 10
Accepted
time: 26ms
memory: 4352kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
32775 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #12:
score: 10
Accepted
time: 74ms
memory: 3968kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 199 1...
output:
32323 1 1 10 1 2 51 1 3 41 1 4 0 1 5 42 1 6 40 1 7 76 1 8 13 1 9 31 1 10 75 1 11 7 1 12 52 1 13 31 1 14 69 1 15 2 1 16 55 1 17 37 1 18 33 1 19 94 1 20 29 1 21 57 1 22 70 1 23 63 1 24 69 1 25 52 1 26 97 1 27 26 1 28 12 1 29 36 1 30 45 1 31 64 1 32 49 1 33 79 1 34 63 1 35 81 1 36 48 1 37 1 1 38 35 1 3...
result:
ok
Test #13:
score: 10
Accepted
time: 27ms
memory: 4132kb
input:
100 100 0 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 9640 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
32666 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #14:
score: 10
Accepted
time: 51ms
memory: 3968kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
31935 1 1 87 1 2 22 1 3 25 1 4 78 1 5 13 1 6 0 1 7 33 1 8 68 1 9 3 1 10 33 1 11 44 1 12 28 1 13 58 1 14 81 1 15 24 1 16 12 1 17 30 1 18 28 1 19 15 1 20 88 1 21 35 1 22 53 1 23 77 1 24 83 1 25 91 1 26 48 1 27 98 1 28 50 1 29 0 1 30 84 1 31 98 1 32 91 1 33 42 1 34 0 1 35 25 1 36 68 1 37 39 1 38 44 1 3...
result:
ok
Test #15:
score: 10
Accepted
time: 50ms
memory: 4136kb
input:
100 100 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 7425 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
31874 1 1 87 1 2 22 1 3 25 1 4 78 1 5 13 1 6 0 1 7 33 1 8 68 1 9 3 1 10 33 1 11 44 1 12 28 1 13 58 1 14 81 1 15 24 1 16 12 1 17 30 1 18 28 1 19 15 1 20 88 1 21 35 1 22 53 1 23 77 1 24 83 1 25 91 1 26 48 1 27 98 1 28 50 1 29 0 1 30 84 1 31 98 1 32 91 1 33 42 1 34 0 1 35 25 1 36 68 1 37 39 1 38 44 1 3...
result:
ok
Test #16:
score: 10
Accepted
time: 118ms
memory: 4108kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
32223 1 1 16 1 2 28 1 3 15 1 4 84 1 5 53 1 6 11 1 7 64 1 8 80 1 9 29 1 10 55 1 11 36 1 12 50 1 13 6 1 14 46 1 15 76 1 16 19 1 17 62 1 18 76 1 19 20 1 20 58 1 21 19 1 22 34 1 23 4 1 24 65 1 25 32 1 26 39 1 27 18 1 28 66 1 29 91 1 30 12 1 31 5 1 32 32 1 33 55 1 34 68 1 35 78 1 36 19 1 37 69 1 38 56 1 ...
result:
ok
Test #17:
score: 10
Accepted
time: 73ms
memory: 3968kb
input:
100 100 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 3019 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 5372 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 9...
output:
32248 1 1 10 1 2 51 1 3 41 1 4 0 1 5 42 1 6 40 1 7 76 1 8 13 1 9 31 1 10 75 1 11 7 1 12 52 1 13 31 1 14 69 1 15 2 1 16 55 1 17 37 1 18 33 1 19 94 1 20 29 1 21 57 1 22 70 1 23 63 1 24 69 1 25 52 1 26 97 1 27 26 1 28 12 1 29 36 1 30 45 1 31 64 1 32 49 1 33 79 1 34 63 1 35 81 1 36 48 1 37 1 1 38 35 1 3...
result:
ok
Test #18:
score: 10
Accepted
time: 27ms
memory: 4028kb
input:
100 100 0 1 2 3 4 5 6 7 8 2609 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...
output:
32754 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #19:
score: 10
Accepted
time: 27ms
memory: 4352kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
32795 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #20:
score: 10
Accepted
time: 49ms
memory: 4128kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
31964 1 1 87 1 2 22 1 3 25 1 4 78 1 5 13 1 6 0 1 7 33 1 8 68 1 9 3 1 10 33 1 11 44 1 12 28 1 13 58 1 14 81 1 15 24 1 16 12 1 17 30 1 18 28 1 19 15 1 20 88 1 21 35 1 22 53 1 23 77 1 24 83 1 25 91 1 26 48 1 27 98 1 28 50 1 29 0 1 30 84 1 31 98 1 32 91 1 33 42 1 34 0 1 35 25 1 36 68 1 37 39 1 38 44 1 3...
result:
ok
Test #21:
score: 10
Accepted
time: 27ms
memory: 4456kb
input:
100 100 0 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...
output:
32775 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Subtask #3:
score: 10
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #22:
score: 10
Accepted
time: 50ms
memory: 4072kb
input:
100 100 2112 2934 7414 365 2258 3340 3507 7202 3045 6498 9486 3256 7054 9492 5725 806 3961 3965 1859 2296 239 723 8010 8641 7735 8437 211 9546 2263 6959 6280 5170 8824 1663 1306 880 5201 7104 2749 6325 8407 1135 70 7599 7188 3353 7612 136 8645 4876 9758 6105 8091 1205 5785 535 1918 546 4385 4457 567...
output:
31320 1 1 87 1 2 22 1 3 25 1 4 78 1 5 13 1 6 0 1 7 33 1 8 68 1 9 3 1 10 33 1 11 44 1 12 28 1 13 58 1 14 81 1 15 24 1 16 12 1 17 30 1 18 28 1 19 15 1 20 88 1 21 35 1 22 53 1 23 77 1 24 83 1 25 91 1 26 48 1 27 98 1 28 50 1 29 0 1 30 84 1 31 98 1 32 91 1 33 42 1 34 0 1 35 25 1 36 68 1 37 39 1 38 44 1 3...
result:
ok
Test #23:
score: 10
Accepted
time: 26ms
memory: 4132kb
input:
100 100 2895 9707 4461 9881 5445 2678 2206 7172 2979 7734 42 217 5379 2102 4724 7336 83 8597 657 4577 4285 3520 1288 2524 8405 9415 962 7290 2282 4328 3057 4045 7584 854 1675 5222 1153 7075 537 7679 7801 1988 1400 4837 1663 7246 6510 6467 6320 7576 7665 9105 8497 5639 3999 1703 7051 8951 9914 2956 4...
output:
31356 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #24:
score: 10
Accepted
time: 116ms
memory: 4056kb
input:
100 100 4468 911 5661 3499 4206 77 5518 9432 2132 338 9185 352 6243 3748 4217 8686 4272 9816 620 2858 5936 9375 7678 9060 7065 2027 2203 1193 5010 6815 8643 7591 5374 8780 2663 7153 9306 9171 569 71 1517 8291 2757 2176 4240 736 415 8096 6408 6612 2195 2960 7659 6944 5132 6148 3136 3627 3827 3312 289...
output:
31327 1 1 16 1 2 28 1 3 15 1 4 84 1 5 53 1 6 11 1 7 64 1 8 80 1 9 29 1 10 55 1 11 36 1 12 50 1 13 6 1 14 46 1 15 76 1 16 19 1 17 62 1 18 76 1 19 20 1 20 58 1 21 19 1 22 34 1 23 4 1 24 65 1 25 32 1 26 39 1 27 18 1 28 66 1 29 91 1 30 12 1 31 5 1 32 32 1 33 55 1 34 68 1 35 78 1 36 19 1 37 69 1 38 56 1 ...
result:
ok
Test #25:
score: 10
Accepted
time: 27ms
memory: 4096kb
input:
100 100 5410 2560 4050 1839 9823 6308 7995 9088 2082 5908 6982 1873 4510 5229 2727 4102 6226 4976 8290 4091 6477 1793 7074 3344 404 7773 3041 8805 2754 9663 3621 9570 4644 4685 8964 4407 2439 169 363 2640 9234 5159 5940 7615 3592 4858 7548 3290 5760 184 3130 4932 3275 2558 2290 9409 3771 9254 8968 8...
output:
31341 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #26:
score: 10
Accepted
time: 25ms
memory: 4132kb
input:
100 100 1195 2668 396 2687 6386 7260 758 3121 2127 7806 9710 9471 9267 4667 8739 8721 164 9028 2638 9480 548 7455 7192 2988 9724 5119 8297 4821 781 8036 3339 1168 9167 1751 3416 9865 7891 7482 7335 5842 7262 6057 2479 1623 5394 7897 6680 5462 7773 4309 5347 7368 8648 7066 3444 5657 3208 2189 2998 91...
output:
31253 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 1 17 19 1 18 4 1 19 97 1 20 6 1 21 9 1 22 9 1 23 43 1 24 39 1 25 46 1 26 26 1 27 36 1 28 53 1 29 60 1 30 71 1 31 12 1 32 9 1 33 29 1 34 18 1 35 26 1 36 95 1 37 53 1 38 93 1 39 87...
result:
ok
Test #27:
score: 10
Accepted
time: 6ms
memory: 4096kb
input:
74 26 1358 1445 1165 279 1851 1629 1065 1880 1458 1263 602 1849 1270 688 1474 1330 700 486 420 1406 1060 828 1577 1354 1646 401 91 1576 1062 651 1314 1652 679 11 261 1089 276 429 203 1092 319 55 724 1555 323 1628 1145 412 254 252 18 1752 918 1433 1649 1878 458 743 1310 1234 13 1093 1672 298 90 147 1...
output:
6192 1 1 23 1 2 6 1 3 3 1 4 10 1 5 25 1 6 10 1 7 15 1 8 22 1 9 15 1 10 9 1 11 16 1 12 14 1 13 6 1 14 7 1 15 12 1 16 8 1 17 14 1 18 0 1 19 19 1 20 8 1 21 21 1 22 7 1 23 11 1 24 25 1 25 21 1 26 20 1 27 16 1 28 24 1 29 16 1 30 22 1 31 0 1 32 17 1 33 16 1 34 0 1 35 11 1 36 6 1 37 17 1 38 14 1 39 8 1 40 ...
result:
ok
Test #28:
score: 10
Accepted
time: 8ms
memory: 3968kb
input:
68 28 1446 1785 68 899 922 1691 1232 1423 906 1051 1210 944 1129 222 205 1058 961 1191 1346 493 361 1683 1394 359 694 838 1381 704 1062 618 1309 318 529 1024 1573 1143 1251 55 1342 1816 1814 932 1179 1422 1318 312 749 971 503 761 1076 1305 1390 669 624 274 632 339 353 1106 1488 26 544 1127 284 733 8...
output:
6113 1 1 11 1 2 0 1 3 24 1 4 20 1 5 9 1 6 4 1 7 16 1 8 4 1 9 17 1 10 14 1 11 1 1 12 1 1 13 6 1 14 0 1 15 3 1 16 27 1 17 1 1 18 17 1 19 19 1 20 25 1 21 17 1 22 11 1 23 16 1 24 12 1 25 9 1 26 0 1 27 5 1 28 5 1 29 16 1 30 24 1 31 8 1 32 4 1 33 21 1 34 23 1 35 5 1 36 25 1 37 12 1 38 0 1 39 20 1 40 12 1 ...
result:
ok
Test #29:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
80 4 147 136 80 287 107 88 58 238 191 227 252 14 275 228 273 67 190 18 3 205 166 247 226 265 16 260 109 69 307 293 245 319 301 59 126 181 72 211 313 281 156 33 50 27 39 157 11 111 22 83 42 10 197 309 79 199 44 274 43 128 266 224 95 12 149 244 145 152 142 151 271 62 6 68 78 219 146 38 229 89 26 7 202...
output:
1109 1 1 0 1 2 2 1 3 2 1 4 1 1 5 0 1 6 3 1 7 1 1 8 1 1 9 2 1 10 3 1 11 3 1 12 1 1 13 0 1 14 2 1 15 3 1 16 0 1 17 3 1 18 0 1 19 1 1 20 2 1 21 1 1 22 1 1 23 3 1 24 3 1 25 2 1 26 2 1 27 0 1 28 1 1 29 0 1 30 3 1 31 0 1 32 1 1 33 1 1 34 2 1 35 2 1 36 3 1 37 1 1 38 1 1 39 3 1 40 0 1 41 0 1 42 2 1 43 3 1 4...
result:
ok
Test #30:
score: 10
Accepted
time: 15ms
memory: 4072kb
input:
74 96 1394 125 6852 6542 1089 4749 763 2819 928 3109 5913 5247 4974 5873 137 4113 59 6086 4963 328 6048 573 6474 4748 5116 6941 5591 1164 5924 219 4542 605 2228 3276 6313 3309 359 4788 6589 5669 5625 6678 5740 5100 5484 5985 3131 706 3284 5347 1813 4956 1948 6261 5196 6457 5187 6383 5280 3967 6749 2...
output:
22471 1 1 92 1 2 54 1 3 14 1 4 89 1 5 76 1 6 31 1 7 5 1 8 65 1 9 90 1 10 43 1 11 67 1 12 5 1 13 36 1 14 90 1 15 95 1 16 48 1 17 39 1 18 4 1 19 25 1 20 58 1 21 65 1 22 49 1 23 83 1 24 55 1 25 42 1 26 50 1 27 88 1 28 57 1 29 28 1 30 59 1 31 60 1 32 45 1 33 49 1 34 26 1 35 78 1 36 7 1 37 73 1 38 77 1 3...
result:
ok
Test #31:
score: 10
Accepted
time: 1ms
memory: 4096kb
input:
16 100 1427 166 1092 1558 171 276 1598 1426 1081 1222 1269 1550 1038 824 572 895 260 57 673 1429 700 1230 65 760 597 74 976 146 1504 539 1399 1314 1330 1494 82 903 518 429 1319 766 675 18 87 377 25 599 325 1059 1055 620 919 364 521 81 118 467 954 796 594 554 809 1343 695 602 1058 851 1486 869 510 71...
output:
5634 1 1 12 1 2 2 1 3 34 1 4 85 1 5 4 1 6 91 1 7 29 1 8 85 1 9 98 1 10 3 1 11 35 1 12 65 1 13 40 1 14 26 1 15 39 1 16 20 2 1 7 2 2 4 2 3 9 2 4 10 2 5 1 2 6 1 2 7 3 2 8 7 2 9 10 2 10 2 2 11 8 2 12 9 2 13 12 2 14 11 2 15 12 2 16 13 2 17 1 2 18 10 2 19 14 2 20 7 2 21 9 2 22 13 2 23 11 2 24 8 2 25 12 2 ...
result:
ok
Test #32:
score: 10
Accepted
time: 7ms
memory: 4096kb
input:
34 58 426 19 479 1691 341 1458 541 1705 1235 421 775 1725 1626 672 1483 1024 1072 255 1027 459 1069 316 1629 927 796 1831 902 1669 923 1280 427 1701 1969 882 854 319 224 802 1088 1136 1058 691 748 178 661 262 1225 1441 1143 118 171 1645 1 1500 1057 1879 1392 1752 393 809 595 1560 585 933 1191 1372 6...
output:
6494 1 1 57 1 2 28 1 3 50 1 4 39 1 5 47 1 6 9 1 7 5 1 8 43 1 9 56 1 10 55 1 11 8 1 12 5 1 13 29 1 14 26 1 15 50 1 16 49 1 17 53 1 18 42 1 19 56 1 20 40 1 21 2 1 22 43 1 23 2 1 24 13 1 25 10 1 26 12 1 27 39 1 28 36 1 29 38 1 30 30 1 31 15 1 32 44 1 33 20 1 34 27 2 1 1 2 2 14 2 3 24 2 4 4 2 5 12 2 6 1...
result:
ok
Test #33:
score: 10
Accepted
time: 4ms
memory: 4096kb
input:
66 30 1399 39 621 1182 719 1270 576 1760 1033 942 1747 1366 1723 1012 1780 285 105 1124 1869 738 300 1801 181 817 1918 1856 650 211 743 546 1110 548 163 1234 1266 1097 1582 1448 363 43 1554 1742 1324 1211 222 1251 428 1642 1497 1013 575 1337 161 703 1738 588 1533 1102 1886 1121 1573 10 1518 698 1534...
output:
6384 1 1 22 1 2 11 1 3 10 1 4 24 1 5 11 1 6 19 1 7 28 1 8 15 1 9 12 1 10 0 1 11 11 1 12 18 1 13 11 1 14 7 1 15 16 1 16 28 1 17 17 1 18 18 1 19 16 1 20 24 1 21 12 1 22 29 1 23 28 1 24 0 1 25 24 1 26 25 1 27 17 1 28 3 1 29 3 1 30 9 1 31 25 1 32 15 1 33 2 1 34 25 1 35 11 1 36 20 1 37 10 1 38 6 1 39 28 ...
result:
ok
Test #34:
score: 10
Accepted
time: 16ms
memory: 4096kb
input:
62 66 4055 461 3187 792 3798 3815 3851 1372 1841 886 2564 1011 208 3067 2169 3837 1195 2026 2147 154 2979 274 1461 1342 1099 738 1764 3899 3878 335 3412 544 1589 3810 1854 3354 3985 509 2738 3579 3099 3778 3222 3722 463 2847 1147 317 484 1392 372 58 1717 662 2680 1019 1445 2093 219 433 1470 2845 138...
output:
13034 1 1 53 1 2 42 1 3 50 1 4 5 1 5 50 1 6 23 1 7 60 1 8 38 1 9 47 1 10 8 1 11 65 1 12 63 1 13 38 1 14 31 1 15 49 1 16 4 1 17 23 1 18 0 1 19 5 1 20 13 1 21 60 1 22 28 1 23 32 1 24 44 1 25 26 1 26 60 1 27 45 1 28 2 1 29 31 1 30 46 1 31 35 1 32 30 1 33 17 1 34 4 1 35 16 1 36 60 1 37 45 1 38 12 1 39 6...
result:
ok
Test #35:
score: 10
Accepted
time: 4ms
memory: 4096kb
input:
20 94 1628 521 938 1190 1824 544 1765 928 259 288 1138 985 1723 1454 737 1558 89 331 1572 1231 981 1845 1484 464 1379 686 1376 470 570 1641 434 1322 1690 1399 873 1323 1058 568 1230 870 1368 1738 76 608 1054 1652 1140 1259 1872 277 333 117 171 310 237 615 1433 265 1562 919 437 1313 342 799 250 1697 ...
output:
6480 1 1 50 1 2 40 1 3 18 1 4 35 1 5 22 1 6 60 1 7 17 1 8 20 1 9 13 1 10 84 1 11 46 1 12 20 1 13 89 1 14 88 1 15 12 1 16 38 1 17 6 1 18 20 1 19 61 1 20 14 2 1 16 2 2 11 2 3 17 2 4 1 2 5 14 2 6 0 2 7 7 2 8 0 2 9 17 2 10 8 2 11 0 2 12 19 2 13 12 2 14 13 2 15 0 2 16 4 2 17 19 2 18 14 2 19 3 2 20 15 2 2...
result:
ok
Test #36:
score: 10
Accepted
time: 3ms
memory: 3968kb
input:
56 28 583 419 478 314 333 693 68 1361 438 159 1045 667 5 1148 360 625 799 187 1478 99 178 678 1163 154 361 1442 149 390 1497 972 18 990 1168 1482 1001 101 1428 847 1365 182 764 145 1513 323 904 1032 1282 23 1505 36 1564 635 513 1205 1390 1392 161 1232 497 30 771 1466 282 845 432 247 1341 1194 812 15...
output:
5099 1 1 8 1 2 14 1 3 22 1 4 1 1 5 16 1 6 27 1 7 9 1 8 5 1 9 14 1 10 11 1 11 27 1 12 17 1 13 4 1 14 14 1 15 27 1 16 0 1 17 27 1 18 24 1 19 1 1 20 26 1 21 1 1 22 17 1 23 23 1 24 23 1 25 6 1 26 14 1 27 16 1 28 13 1 29 16 1 30 27 1 31 4 1 32 21 1 33 1 1 34 2 1 35 22 1 36 27 1 37 21 1 38 13 1 39 23 1 40...
result:
ok
Test #37:
score: 10
Accepted
time: 13ms
memory: 4116kb
input:
72 90 2917 2327 6463 4054 126 1748 1012 355 6308 5660 2730 5653 3321 4466 1386 5373 4728 5359 2505 4937 668 320 3704 4021 1701 549 4501 2163 6213 5656 3085 500 3819 2111 698 2030 3851 5836 5324 4948 4991 5298 1047 1271 2233 5503 3264 3699 1898 1213 3683 255 333 3010 5144 3631 3142 2700 3752 5429 526...
output:
20645 1 1 2 1 2 42 1 3 74 1 4 5 1 5 64 1 6 1 1 7 59 1 8 35 1 9 78 1 10 43 1 11 25 1 12 5 1 13 60 1 14 6 1 15 59 1 16 30 1 17 69 1 18 64 1 19 37 1 20 16 1 21 89 1 22 49 1 23 53 1 24 19 1 25 6 1 26 86 1 27 16 1 28 3 1 29 70 1 30 41 1 31 12 1 32 69 1 33 49 1 34 68 1 35 36 1 36 55 1 37 13 1 38 23 1 39 7...
result:
ok
Test #38:
score: 10
Accepted
time: 4ms
memory: 4096kb
input:
66 20 32 98 660 591 1075 337 1196 1160 765 1013 1215 584 993 486 756 558 570 251 274 404 525 1279 800 469 648 1149 1036 1132 869 909 85 195 407 747 1273 899 786 355 1280 290 413 96 315 1052 1248 1291 1031 201 162 452 430 871 991 437 324 18 706 1091 1156 154 758 819 387 240 146 1125 1262 796 137 1065...
output:
4284 1 1 7 1 2 18 1 3 15 1 4 18 1 5 8 1 6 6 1 7 1 1 8 17 1 9 7 1 10 13 1 11 9 1 12 18 1 13 3 1 14 9 1 15 1 1 16 3 1 17 13 1 18 17 1 19 19 1 20 15 1 21 4 1 22 14 1 23 16 1 24 16 1 25 3 1 26 12 1 27 4 1 28 17 1 29 5 1 30 15 1 31 5 1 32 13 1 33 4 1 34 15 1 35 14 1 36 15 1 37 11 1 38 12 1 39 4 1 40 17 1...
result:
ok
Test #39:
score: 10
Accepted
time: 15ms
memory: 4224kb
input:
74 66 3241 4668 2786 3756 2471 1021 1761 964 2023 2 470 1902 4463 1596 2059 2284 1865 3201 2411 3824 1624 4023 4015 416 171 580 624 4260 653 8 3688 3059 4416 4192 39 4110 2463 660 1101 2387 4701 329 1324 1156 973 1861 4027 372 3287 2725 28 2881 2048 4659 2629 3874 669 3491 4270 2974 4878 2872 4387 4...
output:
15500 1 1 24 1 2 14 1 3 28 1 4 6 1 5 35 1 6 54 1 7 13 1 8 14 1 9 1 1 10 21 1 11 15 1 12 52 1 13 3 1 14 60 1 15 36 1 16 57 1 17 29 1 18 39 1 19 33 1 20 65 1 21 59 1 22 9 1 23 51 1 24 38 1 25 10 1 26 2 1 27 53 1 28 5 1 29 5 1 30 6 1 31 65 1 32 2 1 33 26 1 34 22 1 35 8 1 36 47 1 37 9 1 38 22 1 39 7 1 4...
result:
ok
Test #40:
score: 10
Accepted
time: 7ms
memory: 4092kb
input:
48 64 2712 625 1969 2054 2927 1087 131 122 2749 1294 1457 1761 840 305 821 2813 105 373 1700 1444 141 2295 1073 1901 271 1419 1066 2781 603 2899 900 2620 1377 1593 1650 832 2436 2103 179 1172 2799 1605 1339 1942 1831 874 1301 227 2926 1681 411 2982 447 348 205 1623 2441 1152 2753 1810 748 3030 552 8...
output:
9943 1 1 33 1 2 56 1 3 20 1 4 8 1 5 40 1 6 3 1 7 18 1 8 60 1 9 62 1 10 35 1 11 5 1 12 35 1 13 35 1 14 9 1 15 39 1 16 1 1 17 22 1 18 15 1 19 33 1 20 42 1 21 52 1 22 60 1 23 46 1 24 27 1 25 10 1 26 2 1 27 4 1 28 45 1 29 38 1 30 42 1 31 10 1 32 36 1 33 47 1 34 10 1 35 3 1 36 26 1 37 21 1 38 39 1 39 57 ...
result:
ok
Extra Test:
score: 0
Extra Test Passed