QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#172843#7178. Bishopsucup-team133#WA 19ms5332kbC++231.2kb2023-09-09 20:56:572023-09-09 20:57:00

Judging History

你现在查看的是最新测评结果

  • [2023-09-09 20:57:00]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:5332kb
  • [2023-09-09 20:56:57]
  • 提交

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 {
            int t = m % n;
            if (t == 0) {
                t = 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;
            }
        }
        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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3624kb

input:

2 5

output:

6
1 1
2 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: 3628kb

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: 5332kb

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: 19ms
memory: 5248kb

input:

100000 99999

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: 99999, bishops: 199998

Test #5:

score: 0
Accepted
time: 9ms
memory: 5152kb

input:

100000 50000

output:

149998
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
61...

result:

ok n: 100000, m: 50000, bishops: 149998

Test #6:

score: 0
Accepted
time: 5ms
memory: 4308kb

input:

1 100000

output:

100000
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: 1, m: 100000, bishops: 100000

Test #7:

score: 0
Accepted
time: 13ms
memory: 5196kb

input:

34535 99889

output:

134423
1 1
1 2
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: 6ms
memory: 4168kb

input:

12231 97889

output:

110119
1 1
1 2
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: 4ms
memory: 4284kb

input:

10000 100000

output:

109998
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: 10000, m: 100000, bishops: 109998

Test #10:

score: 0
Accepted
time: 7ms
memory: 4164kb

input:

13 99999

output:

100011
1 1
1 2
1 3
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: -100
Wrong Answer
time: 11ms
memory: 4124kb

input:

21 99999

output:

100018
1 1
1 2
1 3
3 2
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
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
20 3...

result:

wrong answer Participant's answer is not optimal (100018 < 100019)