QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#173050 | #7178. Bishops | ucup-team133# | AC ✓ | 20ms | 5228kb | C++23 | 1.7kb | 2023-09-09 21:44:55 | 2023-09-09 21:44:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
function<vector<pair<int, int>>(int, int)> Solve = [&](int n, int m) {
vector<pair<int, int>> res;
if (n > m) {
res = Solve(m, n);
for (auto& [x, y] : res) {
swap(x, y);
}
} else if (n == m) {
for (int i = 0; i < n; i++) {
res.emplace_back(0, i);
}
for (int i = 1; i < n - 1; i++) {
res.emplace_back(n - 1, i);
}
} else if (m % n) {
int t = m % n;
res = Solve(n, t);
t += n - 1;
while (t < m) {
for (int i = 0; i < n; i++) {
res.emplace_back(i, t);
}
t += n;
}
} else {
int t = m / n;
for (int i = 1; i < t; i++) {
for (int j = 0; j < n; j++) {
res.emplace_back(j, i * n + n - 1);
}
}
for (int j = 0; j < n; j++) {
res.emplace_back(j, 0);
}
if (n % 2 == 0) {
for (int j = 1; j < n - 1; j++) {
res.emplace_back(j, n - 1);
}
} else {
for (int j = (n + 1) / 2; j <= 3 * (n - 1) / 2; j++) {
res.emplace_back(n / 2, j);
}
}
}
return res;
};
int n, m;
cin >> n >> m;
auto a = Solve(n, m);
cout << a.size() << '\n';
for (auto [x, y] : a) {
cout << x + 1 << " " << y + 1 << '\n';
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3432kb
input:
2 5
output:
6 2 1 1 1 1 3 2 3 1 5 2 5
result:
ok n: 2, m: 5, bishops: 6
Test #2:
score: 0
Accepted
time: 1ms
memory: 3436kb
input:
5 5
output:
8 1 1 1 2 1 3 1 4 1 5 5 2 5 3 5 4
result:
ok n: 5, m: 5, bishops: 8
Test #3:
score: 0
Accepted
time: 19ms
memory: 5228kb
input:
100000 100000
output:
199998 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
result:
ok n: 100000, m: 100000, bishops: 199998
Test #4:
score: 0
Accepted
time: 16ms
memory: 5148kb
input:
100000 99999
output:
199998 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1...
result:
ok n: 100000, m: 99999, bishops: 199998
Test #5:
score: 0
Accepted
time: 6ms
memory: 5220kb
input:
100000 50000
output:
149998 100000 1 100000 2 100000 3 100000 4 100000 5 100000 6 100000 7 100000 8 100000 9 100000 10 100000 11 100000 12 100000 13 100000 14 100000 15 100000 16 100000 17 100000 18 100000 19 100000 20 100000 21 100000 22 100000 23 100000 24 100000 25 100000 26 100000 27 100000 28 100000 29 100000 30 10...
result:
ok n: 100000, m: 50000, bishops: 149998
Test #6:
score: 0
Accepted
time: 4ms
memory: 4112kb
input:
1 100000
output:
100000 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1...
result:
ok n: 1, m: 100000, bishops: 100000
Test #7:
score: 0
Accepted
time: 15ms
memory: 5156kb
input:
34535 99889
output:
134423 1 2 1 1 3 1 3 2 5 1 5 2 1 7 2 7 3 7 4 7 5 7 12 1 12 2 12 3 12 4 12 5 12 6 12 7 19 1 19 2 19 3 19 4 19 5 19 6 19 7 26 1 26 2 26 3 26 4 26 5 26 6 26 7 33 1 33 2 33 3 33 4 33 5 33 6 33 7 1 40 2 40 3 40 4 40 5 40 6 40 7 40 8 40 9 40 10 40 11 40 12 40 13 40 14 40 15 40 16 40 17 40 18 40 19 40 20 4...
result:
ok n: 34535, m: 99889, bishops: 134423
Test #8:
score: 0
Accepted
time: 12ms
memory: 4128kb
input:
12231 97889
output:
110119 1 2 1 1 3 1 3 2 5 1 5 2 7 1 7 2 9 1 9 2 11 1 11 2 13 1 13 2 1 15 2 15 3 15 4 15 5 15 6 15 7 15 8 15 9 15 10 15 11 15 12 15 13 15 1 28 2 28 3 28 4 28 5 28 6 28 7 28 8 28 9 28 10 28 11 28 12 28 13 28 1 41 2 41 3 41 4 41 5 41 6 41 7 41 8 41 9 41 10 41 11 41 12 41 13 41 54 1 54 2 54 3 54 4 54 5 5...
result:
ok n: 12231, m: 97889, bishops: 110119
Test #9:
score: 0
Accepted
time: 9ms
memory: 4148kb
input:
10000 100000
output:
109998 1 20000 2 20000 3 20000 4 20000 5 20000 6 20000 7 20000 8 20000 9 20000 10 20000 11 20000 12 20000 13 20000 14 20000 15 20000 16 20000 17 20000 18 20000 19 20000 20 20000 21 20000 22 20000 23 20000 24 20000 25 20000 26 20000 27 20000 28 20000 29 20000 30 20000 31 20000 32 20000 33 20000 34 20...
result:
ok n: 10000, m: 100000, bishops: 109998
Test #10:
score: 0
Accepted
time: 6ms
memory: 4116kb
input:
13 99999
output:
100011 1 2 1 3 1 1 4 1 4 2 4 3 7 1 7 2 7 3 10 1 10 2 10 3 13 1 13 2 13 3 1 16 2 16 3 16 4 16 5 16 6 16 7 16 8 16 9 16 10 16 11 16 12 16 13 16 1 29 2 29 3 29 4 29 5 29 6 29 7 29 8 29 9 29 10 29 11 29 12 29 13 29 1 42 2 42 3 42 4 42 5 42 6 42 7 42 8 42 9 42 10 42 11 42 12 42 13 42 1 55 2 55 3 55 4 55 ...
result:
ok n: 13, m: 99999, bishops: 100011
Test #11:
score: 0
Accepted
time: 7ms
memory: 4140kb
input:
21 99999
output:
100019 1 6 2 6 3 6 1 9 2 9 3 9 1 12 2 12 3 12 1 15 2 15 3 15 1 18 2 18 3 18 1 1 2 1 3 1 2 3 2 4 21 1 21 2 21 3 21 4 21 5 21 6 21 7 21 8 21 9 21 10 21 11 21 12 21 13 21 14 21 15 21 16 21 17 21 18 1 39 2 39 3 39 4 39 5 39 6 39 7 39 8 39 9 39 10 39 11 39 12 39 13 39 14 39 15 39 16 39 17 39 18 39 19 39 ...
result:
ok n: 21, m: 99999, bishops: 100019
Test #12:
score: 0
Accepted
time: 12ms
memory: 5076kb
input:
49999 100000
output:
149998 1 2 1 1 3 1 3 2 5 1 5 2 7 1 7 2 9 1 9 2 11 1 11 2 13 1 13 2 15 1 15 2 17 1 17 2 19 1 19 2 21 1 21 2 23 1 23 2 25 1 25 2 27 1 27 2 29 1 29 2 31 1 31 2 33 1 33 2 35 1 35 2 37 1 37 2 39 1 39 2 41 1 41 2 43 1 43 2 45 1 45 2 47 1 47 2 49 1 49 2 51 1 51 2 53 1 53 2 55 1 55 2 57 1 57 2 59 1 59 2 61 ...
result:
ok n: 49999, m: 100000, bishops: 149998
Test #13:
score: 0
Accepted
time: 15ms
memory: 5156kb
input:
33333 99999
output:
133331 1 66666 2 66666 3 66666 4 66666 5 66666 6 66666 7 66666 8 66666 9 66666 10 66666 11 66666 12 66666 13 66666 14 66666 15 66666 16 66666 17 66666 18 66666 19 66666 20 66666 21 66666 22 66666 23 66666 24 66666 25 66666 26 66666 27 66666 28 66666 29 66666 30 66666 31 66666 32 66666 33 66666 34 66...
result:
ok n: 33333, m: 99999, bishops: 133331
Test #14:
score: 0
Accepted
time: 13ms
memory: 4104kb
input:
23342 98876
output:
122216 4 1 4 2 6 1 6 2 8 1 8 2 10 1 10 2 12 1 12 2 14 1 14 2 16 1 16 2 18 1 18 2 20 1 20 2 22 1 22 2 24 1 24 2 26 1 26 2 28 1 28 2 1 1 1 2 1 30 2 30 3 30 4 30 5 30 6 30 7 30 8 30 9 30 10 30 11 30 12 30 13 30 14 30 15 30 16 30 17 30 18 30 19 30 20 30 21 30 22 30 23 30 24 30 25 30 26 30 27 30 28 30 58...
result:
ok n: 23342, m: 98876, bishops: 122216
Test #15:
score: 0
Accepted
time: 16ms
memory: 5124kb
input:
56713 91234
output:
147946 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 6...
result:
ok n: 56713, m: 91234, bishops: 147946
Test #16:
score: 0
Accepted
time: 14ms
memory: 5132kb
input:
99995 99995
output:
199988 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 ...
result:
ok n: 99995, m: 99995, bishops: 199988
Test #17:
score: 0
Accepted
time: 4ms
memory: 4064kb
input:
12345 54321
output:
66665 1 6 2 6 3 6 1 9 2 9 3 9 1 12 2 12 3 12 1 15 2 15 3 15 1 1 2 1 3 1 2 3 2 4 18 1 18 2 18 3 18 4 18 5 18 6 18 7 18 8 18 9 18 10 18 11 18 12 18 13 18 14 18 15 33 1 33 2 33 3 33 4 33 5 33 6 33 7 33 8 33 9 33 10 33 11 33 12 33 13 33 14 33 15 48 1 48 2 48 3 48 4 48 5 48 6 48 7 48 8 48 9 48 10 48 11 4...
result:
ok n: 12345, m: 54321, bishops: 66665
Test #18:
score: 0
Accepted
time: 20ms
memory: 5224kb
input:
90000 92000
output:
181998 4000 1 4000 2 4000 3 4000 4 4000 5 4000 6 4000 7 4000 8 4000 9 4000 10 4000 11 4000 12 4000 13 4000 14 4000 15 4000 16 4000 17 4000 18 4000 19 4000 20 4000 21 4000 22 4000 23 4000 24 4000 25 4000 26 4000 27 4000 28 4000 29 4000 30 4000 31 4000 32 4000 33 4000 34 4000 35 4000 36 4000 37 4000 3...
result:
ok n: 90000, m: 92000, bishops: 181998
Test #19:
score: 0
Accepted
time: 11ms
memory: 4116kb
input:
10000 70000
output:
79998 1 20000 2 20000 3 20000 4 20000 5 20000 6 20000 7 20000 8 20000 9 20000 10 20000 11 20000 12 20000 13 20000 14 20000 15 20000 16 20000 17 20000 18 20000 19 20000 20 20000 21 20000 22 20000 23 20000 24 20000 25 20000 26 20000 27 20000 28 20000 29 20000 30 20000 31 20000 32 20000 33 20000 34 200...
result:
ok n: 10000, m: 70000, bishops: 79998
Test #20:
score: 0
Accepted
time: 4ms
memory: 4132kb
input:
10000 70001
output:
80000 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62...
result:
ok n: 10000, m: 70001, bishops: 80000
Test #21:
score: 0
Accepted
time: 5ms
memory: 4140kb
input:
10000 80000
output:
89998 1 20000 2 20000 3 20000 4 20000 5 20000 6 20000 7 20000 8 20000 9 20000 10 20000 11 20000 12 20000 13 20000 14 20000 15 20000 16 20000 17 20000 18 20000 19 20000 20 20000 21 20000 22 20000 23 20000 24 20000 25 20000 26 20000 27 20000 28 20000 29 20000 30 20000 31 20000 32 20000 33 20000 34 200...
result:
ok n: 10000, m: 80000, bishops: 89998
Test #22:
score: 0
Accepted
time: 1ms
memory: 4080kb
input:
10000 80001
output:
90000 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62...
result:
ok n: 10000, m: 80001, bishops: 90000
Test #23:
score: 0
Accepted
time: 11ms
memory: 4104kb
input:
10000 80002
output:
90000 4 1 4 2 6 1 6 2 8 1 8 2 10 1 10 2 12 1 12 2 14 1 14 2 16 1 16 2 18 1 18 2 20 1 20 2 22 1 22 2 24 1 24 2 26 1 26 2 28 1 28 2 30 1 30 2 32 1 32 2 34 1 34 2 36 1 36 2 38 1 38 2 40 1 40 2 42 1 42 2 44 1 44 2 46 1 46 2 48 1 48 2 50 1 50 2 52 1 52 2 54 1 54 2 56 1 56 2 58 1 58 2 60 1 60 2 62 1 62 2 ...
result:
ok n: 10000, m: 80002, bishops: 90000
Test #24:
score: 0
Accepted
time: 10ms
memory: 4180kb
input:
10000 79999
output:
89998 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 ...
result:
ok n: 10000, m: 79999, bishops: 89998
Test #25:
score: 0
Accepted
time: 10ms
memory: 4136kb
input:
10000 79998
output:
89996 1 4 2 4 1 6 2 6 1 8 2 8 1 10 2 10 1 12 2 12 1 14 2 14 1 16 2 16 1 18 2 18 1 20 2 20 1 22 2 22 1 24 2 24 1 26 2 26 1 28 2 28 1 30 2 30 1 32 2 32 1 34 2 34 1 36 2 36 1 38 2 38 1 40 2 40 1 42 2 42 1 44 2 44 1 46 2 46 1 48 2 48 1 50 2 50 1 52 2 52 1 54 2 54 1 56 2 56 1 58 2 58 1 60 2 60 1 62 2 62 ...
result:
ok n: 10000, m: 79998, bishops: 89996
Test #26:
score: 0
Accepted
time: 9ms
memory: 4088kb
input:
11111 100000
output:
111110 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 6...
result:
ok n: 11111, m: 100000, bishops: 111110
Test #27:
score: 0
Accepted
time: 1ms
memory: 3440kb
input:
1 1
output:
1 1 1
result:
ok n: 1, m: 1, bishops: 1
Extra Test:
score: 0
Extra Test Passed