QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#875358#7178. BishopsHeyJinhwi#AC ✓14ms6500kbC++141.9kb2025-01-29 16:37:502025-01-29 16:37:51

Judging History

This is the latest submission verdict.

  • [2025-01-29 16:37:51]
  • Judged
  • Verdict: AC
  • Time: 14ms
  • Memory: 6500kb
  • [2025-01-29 16:37:50]
  • Submitted

answer

#include <iostream>
#include <vector>

using namespace std;
typedef pair<int,int> pi;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m;cin>>n>>m;
    int flag=0;
    vector<pi> ans;
    if(n>m)
    {
        flag=1;
        int t=n;
        n=m;
        m=t;
    }
    if(n==m)
    {
        if(n==1)cout<<"1\n";
        else cout<<n*2-2<<'\n';
        for(int i=1;i<=n;i++)
        {
            cout<<"1 "<<i<<'\n';
        }
        for(int i=2;i<n;i++)
        {
            cout<<n<<' '<<i<<'\n';
        }
        return 0;
    }
    else if(n%2==1)
    {
        for(int i=1;i<=n;i++)
        {
            if(i%2)ans.push_back({i,1});
            if(i%2==m%2)ans.push_back({i,m});
        }
        int lb=n/2+2,rb=n/2+2;
        if(m%2==0)rb--;
        for(int i=1+lb;i<=m-rb;i+=2)
        {
            ans.push_back({n/2+1,i});
        }

        for(int i=1;i<=n;i++)
        {
            if(i%2==0)ans.push_back({i,1});
            if(i%2!=m%2)ans.push_back({i,m});
        }
        lb=n/2+1,rb=n/2+2;
        if(m%2==1)rb--;
        for(int i=1+lb;i<=m-rb;i+=2)
        {
            ans.push_back({n/2+1,i});
        }
    }
    else
    {
        for(int i=1;i<=n;i++)
        {
            if(i%2)
            {
                ans.push_back({i,1});
                ans.push_back({n+1-i,1});
            }
            if(i%2==m%2)
            {
                ans.push_back({i,m});
                ans.push_back({n+1-i,m});
            }
        }
        int lb=n/2+1,rb=n/2+1;
        if(m%2==0)rb++;
        for(int i=1+lb;i<=m-rb;i+=2)
        {
            ans.push_back({n/2,i});
            ans.push_back({n+1-n/2,i});
        }
    }
    cout<<ans.size()<<'\n';
    for(int i=0;i<ans.size();i++)
    {
        if(flag)cout<<ans[i].second<<' '<<ans[i].first<<'\n';
        else cout<<ans[i].first<<' '<<ans[i].second<<'\n';
    }
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3712kb

input:

2 5

output:

6
1 1
2 1
1 5
2 5
1 3
2 3

result:

ok n: 2, m: 5, bishops: 6

Test #2:

score: 0
Accepted
time: 0ms
memory: 3712kb

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: 12ms
memory: 3584kb

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: 14ms
memory: 6500kb

input:

100000 99999

output:

199998
1 1
100000 2
1 3
100000 4
1 5
100000 6
1 7
100000 8
1 9
100000 10
1 11
100000 12
1 13
100000 14
1 15
100000 16
1 17
100000 18
1 19
100000 20
1 21
100000 22
1 23
100000 24
1 25
100000 26
1 27
100000 28
1 29
100000 30
1 31
100000 32
1 33
100000 34
1 35
100000 36
1 37
100000 38
1 39
100000 40
1 ...

result:

ok n: 100000, m: 99999, bishops: 199998

Test #5:

score: 0
Accepted
time: 10ms
memory: 6500kb

input:

100000 50000

output:

149998
1 1
1 50000
100000 2
100000 49999
1 3
1 49998
100000 4
100000 49997
1 5
1 49996
100000 6
100000 49995
1 7
1 49994
100000 8
100000 49993
1 9
1 49992
100000 10
100000 49991
1 11
1 49990
100000 12
100000 49989
1 13
1 49988
100000 14
100000 49987
1 15
1 49986
100000 16
100000 49985
1 17
1 49984
1...

result:

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

Test #6:

score: 0
Accepted
time: 6ms
memory: 4452kb

input:

1 100000

output:

100000
1 1
1 3
1 5
1 7
1 9
1 11
1 13
1 15
1 17
1 19
1 21
1 23
1 25
1 27
1 29
1 31
1 33
1 35
1 37
1 39
1 41
1 43
1 45
1 47
1 49
1 51
1 53
1 55
1 57
1 59
1 61
1 63
1 65
1 67
1 69
1 71
1 73
1 75
1 77
1 79
1 81
1 83
1 85
1 87
1 89
1 91
1 93
1 95
1 97
1 99
1 101
1 103
1 105
1 107
1 109
1 111
1 113
1 115
...

result:

ok n: 1, m: 100000, bishops: 100000

Test #7:

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

input:

34535 99889

output:

134423
1 1
1 99889
3 1
3 99889
5 1
5 99889
7 1
7 99889
9 1
9 99889
11 1
11 99889
13 1
13 99889
15 1
15 99889
17 1
17 99889
19 1
19 99889
21 1
21 99889
23 1
23 99889
25 1
25 99889
27 1
27 99889
29 1
29 99889
31 1
31 99889
33 1
33 99889
35 1
35 99889
37 1
37 99889
39 1
39 99889
41 1
41 99889
43 1
43 9...

result:

ok n: 34535, m: 99889, bishops: 134423

Test #8:

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

input:

12231 97889

output:

110119
1 1
1 97889
3 1
3 97889
5 1
5 97889
7 1
7 97889
9 1
9 97889
11 1
11 97889
13 1
13 97889
15 1
15 97889
17 1
17 97889
19 1
19 97889
21 1
21 97889
23 1
23 97889
25 1
25 97889
27 1
27 97889
29 1
29 97889
31 1
31 97889
33 1
33 97889
35 1
35 97889
37 1
37 97889
39 1
39 97889
41 1
41 97889
43 1
43 9...

result:

ok n: 12231, m: 97889, bishops: 110119

Test #9:

score: 0
Accepted
time: 8ms
memory: 4456kb

input:

10000 100000

output:

109998
1 1
10000 1
2 100000
9999 100000
3 1
9998 1
4 100000
9997 100000
5 1
9996 1
6 100000
9995 100000
7 1
9994 1
8 100000
9993 100000
9 1
9992 1
10 100000
9991 100000
11 1
9990 1
12 100000
9989 100000
13 1
9988 1
14 100000
9987 100000
15 1
9986 1
16 100000
9985 100000
17 1
9984 1
18 100000
9983 10...

result:

ok n: 10000, m: 100000, bishops: 109998

Test #10:

score: 0
Accepted
time: 8ms
memory: 4380kb

input:

13 99999

output:

100011
1 1
1 99999
3 1
3 99999
5 1
5 99999
7 1
7 99999
9 1
9 99999
11 1
11 99999
13 1
13 99999
7 9
7 11
7 13
7 15
7 17
7 19
7 21
7 23
7 25
7 27
7 29
7 31
7 33
7 35
7 37
7 39
7 41
7 43
7 45
7 47
7 49
7 51
7 53
7 55
7 57
7 59
7 61
7 63
7 65
7 67
7 69
7 71
7 73
7 75
7 77
7 79
7 81
7 83
7 85
7 87
7 89
7...

result:

ok n: 13, m: 99999, bishops: 100011

Test #11:

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

input:

21 99999

output:

100019
1 1
1 99999
3 1
3 99999
5 1
5 99999
7 1
7 99999
9 1
9 99999
11 1
11 99999
13 1
13 99999
15 1
15 99999
17 1
17 99999
19 1
19 99999
21 1
21 99999
11 13
11 15
11 17
11 19
11 21
11 23
11 25
11 27
11 29
11 31
11 33
11 35
11 37
11 39
11 41
11 43
11 45
11 47
11 49
11 51
11 53
11 55
11 57
11 59
11 61...

result:

ok n: 21, m: 99999, bishops: 100019

Test #12:

score: 0
Accepted
time: 11ms
memory: 6500kb

input:

49999 100000

output:

149998
1 1
2 100000
3 1
4 100000
5 1
6 100000
7 1
8 100000
9 1
10 100000
11 1
12 100000
13 1
14 100000
15 1
16 100000
17 1
18 100000
19 1
20 100000
21 1
22 100000
23 1
24 100000
25 1
26 100000
27 1
28 100000
29 1
30 100000
31 1
32 100000
33 1
34 100000
35 1
36 100000
37 1
38 100000
39 1
40 100000
41...

result:

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

Test #13:

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

input:

33333 99999

output:

133331
1 1
1 99999
3 1
3 99999
5 1
5 99999
7 1
7 99999
9 1
9 99999
11 1
11 99999
13 1
13 99999
15 1
15 99999
17 1
17 99999
19 1
19 99999
21 1
21 99999
23 1
23 99999
25 1
25 99999
27 1
27 99999
29 1
29 99999
31 1
31 99999
33 1
33 99999
35 1
35 99999
37 1
37 99999
39 1
39 99999
41 1
41 99999
43 1
43 9...

result:

ok n: 33333, m: 99999, bishops: 133331

Test #14:

score: 0
Accepted
time: 6ms
memory: 4452kb

input:

23342 98876

output:

122216
1 1
23342 1
2 98876
23341 98876
3 1
23340 1
4 98876
23339 98876
5 1
23338 1
6 98876
23337 98876
7 1
23336 1
8 98876
23335 98876
9 1
23334 1
10 98876
23333 98876
11 1
23332 1
12 98876
23331 98876
13 1
23330 1
14 98876
23329 98876
15 1
23328 1
16 98876
23327 98876
17 1
23326 1
18 98876
23325 98...

result:

ok n: 23342, m: 98876, bishops: 122216

Test #15:

score: 0
Accepted
time: 10ms
memory: 6388kb

input:

56713 91234

output:

147946
1 1
2 91234
3 1
4 91234
5 1
6 91234
7 1
8 91234
9 1
10 91234
11 1
12 91234
13 1
14 91234
15 1
16 91234
17 1
18 91234
19 1
20 91234
21 1
22 91234
23 1
24 91234
25 1
26 91234
27 1
28 91234
29 1
30 91234
31 1
32 91234
33 1
34 91234
35 1
36 91234
37 1
38 91234
39 1
40 91234
41 1
42 91234
43 1
44 ...

result:

ok n: 56713, m: 91234, bishops: 147946

Test #16:

score: 0
Accepted
time: 11ms
memory: 3712kb

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

input:

12345 54321

output:

66665
1 1
1 54321
3 1
3 54321
5 1
5 54321
7 1
7 54321
9 1
9 54321
11 1
11 54321
13 1
13 54321
15 1
15 54321
17 1
17 54321
19 1
19 54321
21 1
21 54321
23 1
23 54321
25 1
25 54321
27 1
27 54321
29 1
29 54321
31 1
31 54321
33 1
33 54321
35 1
35 54321
37 1
37 54321
39 1
39 54321
41 1
41 54321
43 1
43 54...

result:

ok n: 12345, m: 54321, bishops: 66665

Test #18:

score: 0
Accepted
time: 12ms
memory: 6392kb

input:

90000 92000

output:

181998
1 1
90000 1
2 92000
89999 92000
3 1
89998 1
4 92000
89997 92000
5 1
89996 1
6 92000
89995 92000
7 1
89994 1
8 92000
89993 92000
9 1
89992 1
10 92000
89991 92000
11 1
89990 1
12 92000
89989 92000
13 1
89988 1
14 92000
89987 92000
15 1
89986 1
16 92000
89985 92000
17 1
89984 1
18 92000
89983 92...

result:

ok n: 90000, m: 92000, bishops: 181998

Test #19:

score: 0
Accepted
time: 4ms
memory: 4452kb

input:

10000 70000

output:

79998
1 1
10000 1
2 70000
9999 70000
3 1
9998 1
4 70000
9997 70000
5 1
9996 1
6 70000
9995 70000
7 1
9994 1
8 70000
9993 70000
9 1
9992 1
10 70000
9991 70000
11 1
9990 1
12 70000
9989 70000
13 1
9988 1
14 70000
9987 70000
15 1
9986 1
16 70000
9985 70000
17 1
9984 1
18 70000
9983 70000
19 1
9982 1
20...

result:

ok n: 10000, m: 70000, bishops: 79998

Test #20:

score: 0
Accepted
time: 6ms
memory: 4452kb

input:

10000 70001

output:

80000
1 1
10000 1
1 70001
10000 70001
3 1
9998 1
3 70001
9998 70001
5 1
9996 1
5 70001
9996 70001
7 1
9994 1
7 70001
9994 70001
9 1
9992 1
9 70001
9992 70001
11 1
9990 1
11 70001
9990 70001
13 1
9988 1
13 70001
9988 70001
15 1
9986 1
15 70001
9986 70001
17 1
9984 1
17 70001
9984 70001
19 1
9982 1
19...

result:

ok n: 10000, m: 70001, bishops: 80000

Test #21:

score: 0
Accepted
time: 4ms
memory: 4448kb

input:

10000 80000

output:

89998
1 1
10000 1
2 80000
9999 80000
3 1
9998 1
4 80000
9997 80000
5 1
9996 1
6 80000
9995 80000
7 1
9994 1
8 80000
9993 80000
9 1
9992 1
10 80000
9991 80000
11 1
9990 1
12 80000
9989 80000
13 1
9988 1
14 80000
9987 80000
15 1
9986 1
16 80000
9985 80000
17 1
9984 1
18 80000
9983 80000
19 1
9982 1
20...

result:

ok n: 10000, m: 80000, bishops: 89998

Test #22:

score: 0
Accepted
time: 6ms
memory: 4360kb

input:

10000 80001

output:

90000
1 1
10000 1
1 80001
10000 80001
3 1
9998 1
3 80001
9998 80001
5 1
9996 1
5 80001
9996 80001
7 1
9994 1
7 80001
9994 80001
9 1
9992 1
9 80001
9992 80001
11 1
9990 1
11 80001
9990 80001
13 1
9988 1
13 80001
9988 80001
15 1
9986 1
15 80001
9986 80001
17 1
9984 1
17 80001
9984 80001
19 1
9982 1
19...

result:

ok n: 10000, m: 80001, bishops: 90000

Test #23:

score: 0
Accepted
time: 8ms
memory: 4320kb

input:

10000 80002

output:

90000
1 1
10000 1
2 80002
9999 80002
3 1
9998 1
4 80002
9997 80002
5 1
9996 1
6 80002
9995 80002
7 1
9994 1
8 80002
9993 80002
9 1
9992 1
10 80002
9991 80002
11 1
9990 1
12 80002
9989 80002
13 1
9988 1
14 80002
9987 80002
15 1
9986 1
16 80002
9985 80002
17 1
9984 1
18 80002
9983 80002
19 1
9982 1
20...

result:

ok n: 10000, m: 80002, bishops: 90000

Test #24:

score: 0
Accepted
time: 6ms
memory: 4408kb

input:

10000 79999

output:

89998
1 1
10000 1
1 79999
10000 79999
3 1
9998 1
3 79999
9998 79999
5 1
9996 1
5 79999
9996 79999
7 1
9994 1
7 79999
9994 79999
9 1
9992 1
9 79999
9992 79999
11 1
9990 1
11 79999
9990 79999
13 1
9988 1
13 79999
9988 79999
15 1
9986 1
15 79999
9986 79999
17 1
9984 1
17 79999
9984 79999
19 1
9982 1
19...

result:

ok n: 10000, m: 79999, bishops: 89998

Test #25:

score: 0
Accepted
time: 4ms
memory: 4456kb

input:

10000 79998

output:

89996
1 1
10000 1
2 79998
9999 79998
3 1
9998 1
4 79998
9997 79998
5 1
9996 1
6 79998
9995 79998
7 1
9994 1
8 79998
9993 79998
9 1
9992 1
10 79998
9991 79998
11 1
9990 1
12 79998
9989 79998
13 1
9988 1
14 79998
9987 79998
15 1
9986 1
16 79998
9985 79998
17 1
9984 1
18 79998
9983 79998
19 1
9982 1
20...

result:

ok n: 10000, m: 79998, bishops: 89996

Test #26:

score: 0
Accepted
time: 6ms
memory: 4456kb

input:

11111 100000

output:

111110
1 1
2 100000
3 1
4 100000
5 1
6 100000
7 1
8 100000
9 1
10 100000
11 1
12 100000
13 1
14 100000
15 1
16 100000
17 1
18 100000
19 1
20 100000
21 1
22 100000
23 1
24 100000
25 1
26 100000
27 1
28 100000
29 1
30 100000
31 1
32 100000
33 1
34 100000
35 1
36 100000
37 1
38 100000
39 1
40 100000
41...

result:

ok n: 11111, m: 100000, bishops: 111110

Test #27:

score: 0
Accepted
time: 0ms
memory: 3584kb

input:

1 1

output:

1
1 1

result:

ok n: 1, m: 1, bishops: 1

Extra Test:

score: 0
Extra Test Passed