QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875387#7178. Bishopsshinonome_ena#WA 13ms9816kbC++141.8kb2025-01-29 17:23:562025-01-29 17:23:56

Judging History

This is the latest submission verdict.

  • [2025-01-29 17:23:56]
  • Judged
  • Verdict: WA
  • Time: 13ms
  • Memory: 9816kb
  • [2025-01-29 17:23:56]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n,m,i,j,k,l,r,x,y,z,w,s,t,sp,a[1100][1100];
vector<pair<ll,ll>> ans;
void answer()
{
    printf("%d\n",ans.size());
    for(auto pp:ans)
    {
        x=pp.first;
        y=pp.second;
        //a[x][y]=1;
        if(sp)
            swap(x,y);
        printf("%lld %lld\n",x,y);
    }
    return;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
            printf("%lld",a[i][j]);
        printf("\n");
    }
}
int main()
{
    scanf("%lld %lld",&n,&m);
    if(n>m)
    {swap(n,m);
    sp=1;
    }
    if(n==1||(n==2&&m%2==0))
    {
        for(i=1;i<=m;i++)
        ans.push_back({1,i});
        answer();
        return 0;
    }
    if(n==2)
    {
        for(i=1;i<=m;i+=2)
        {
            ans.push_back({1,i});
            ans.push_back({2,i});
        }
        answer();
        return 0;
    }
    if(n==m)
    {
        printf("%lld\n",n*2-2);
        for(i=1;i<=n-1;i++)
        {
            printf("%lld 1\n%lld %lld\n",i,i,n);
        }
        return 0;
    }
    if((n%2==1&&n+2>=m)||(n%2==0))
    {for(i=1;i<=n;i++)
    {
        ans.push_back({i,1});
        ans.push_back({i,m});
    }}
    else
    {
        t=1;
        for(i=1;i<=n;i+=2)
        {
            ans.push_back({i,1});
            ans.push_back({i,2});
            ans.push_back({i,m-1});
            ans.push_back({i,m});
        }
    }
    if(n%2==1||(n%2==0&&m%2==0))
    {
        for(i=(n+2)/2+1+t;i<=m-(n+2)/2-t;i++)
        {
            ans.push_back({(n+1)/2,i});
        }
    }
    else
    {
        for(i=n/2+1;i<=m-n/2;i+=2)
        {
            ans.push_back({n/2,i});
            ans.push_back({n/2+1,i});
        }
    }
    answer();
}

詳細信息

Test #1:

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

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: 0ms
memory: 3840kb

input:

5 5

output:

8
1 1
1 5
2 1
2 5
3 1
3 5
4 1
4 5

result:

ok n: 5, m: 5, bishops: 8

Test #3:

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

input:

100000 100000

output:

199998
1 1
1 100000
2 1
2 100000
3 1
3 100000
4 1
4 100000
5 1
5 100000
6 1
6 100000
7 1
7 100000
8 1
8 100000
9 1
9 100000
10 1
10 100000
11 1
11 100000
12 1
12 100000
13 1
13 100000
14 1
14 100000
15 1
15 100000
16 1
16 100000
17 1
17 100000
18 1
18 100000
19 1
19 100000
20 1
20 100000
21 1
21 100...

result:

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

Test #4:

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

input:

100000 99999

output:

199998
1 1
100000 1
1 2
100000 2
1 3
100000 3
1 4
100000 4
1 5
100000 5
1 6
100000 6
1 7
100000 7
1 8
100000 8
1 9
100000 9
1 10
100000 10
1 11
100000 11
1 12
100000 12
1 13
100000 13
1 14
100000 14
1 15
100000 15
1 16
100000 16
1 17
100000 17
1 18
100000 18
1 19
100000 19
1 20
100000 20
1 21
100000...

result:

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

Test #5:

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

input:

100000 50000

output:

149998
1 1
100000 1
1 2
100000 2
1 3
100000 3
1 4
100000 4
1 5
100000 5
1 6
100000 6
1 7
100000 7
1 8
100000 8
1 9
100000 9
1 10
100000 10
1 11
100000 11
1 12
100000 12
1 13
100000 13
1 14
100000 14
1 15
100000 15
1 16
100000 16
1 17
100000 17
1 18
100000 18
1 19
100000 19
1 20
100000 20
1 21
100000...

result:

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

Test #6:

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

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: 11ms
memory: 9808kb

input:

34535 99889

output:

134423
1 1
1 2
1 99888
1 99889
3 1
3 2
3 99888
3 99889
5 1
5 2
5 99888
5 99889
7 1
7 2
7 99888
7 99889
9 1
9 2
9 99888
9 99889
11 1
11 2
11 99888
11 99889
13 1
13 2
13 99888
13 99889
15 1
15 2
15 99888
15 99889
17 1
17 2
17 99888
17 99889
19 1
19 2
19 99888
19 99889
21 1
21 2
21 99888
21 99889
23 1
...

result:

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

Test #8:

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

input:

12231 97889

output:

110119
1 1
1 2
1 97888
1 97889
3 1
3 2
3 97888
3 97889
5 1
5 2
5 97888
5 97889
7 1
7 2
7 97888
7 97889
9 1
9 2
9 97888
9 97889
11 1
11 2
11 97888
11 97889
13 1
13 2
13 97888
13 97889
15 1
15 2
15 97888
15 97889
17 1
17 2
17 97888
17 97889
19 1
19 2
19 97888
19 97889
21 1
21 2
21 97888
21 97889
23 1
...

result:

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

Test #9:

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

input:

10000 100000

output:

109998
1 1
1 100000
2 1
2 100000
3 1
3 100000
4 1
4 100000
5 1
5 100000
6 1
6 100000
7 1
7 100000
8 1
8 100000
9 1
9 100000
10 1
10 100000
11 1
11 100000
12 1
12 100000
13 1
13 100000
14 1
14 100000
15 1
15 100000
16 1
16 100000
17 1
17 100000
18 1
18 100000
19 1
19 100000
20 1
20 100000
21 1
21 100...

result:

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

Test #10:

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

input:

13 99999

output:

100011
1 1
1 2
1 99998
1 99999
3 1
3 2
3 99998
3 99999
5 1
5 2
5 99998
5 99999
7 1
7 2
7 99998
7 99999
9 1
9 2
9 99998
9 99999
11 1
11 2
11 99998
11 99999
13 1
13 2
13 99998
13 99999
7 9
7 10
7 11
7 12
7 13
7 14
7 15
7 16
7 17
7 18
7 19
7 20
7 21
7 22
7 23
7 24
7 25
7 26
7 27
7 28
7 29
7 30
7 31
7 3...

result:

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

Test #11:

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

input:

21 99999

output:

100019
1 1
1 2
1 99998
1 99999
3 1
3 2
3 99998
3 99999
5 1
5 2
5 99998
5 99999
7 1
7 2
7 99998
7 99999
9 1
9 2
9 99998
9 99999
11 1
11 2
11 99998
11 99999
13 1
13 2
13 99998
13 99999
15 1
15 2
15 99998
15 99999
17 1
17 2
17 99998
17 99999
19 1
19 2
19 99998
19 99999
21 1
21 2
21 99998
21 99999
11 13...

result:

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

Test #12:

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

input:

49999 100000

output:

149998
1 1
1 2
1 99999
1 100000
3 1
3 2
3 99999
3 100000
5 1
5 2
5 99999
5 100000
7 1
7 2
7 99999
7 100000
9 1
9 2
9 99999
9 100000
11 1
11 2
11 99999
11 100000
13 1
13 2
13 99999
13 100000
15 1
15 2
15 99999
15 100000
17 1
17 2
17 99999
17 100000
19 1
19 2
19 99999
19 100000
21 1
21 2
21 99999
21 1...

result:

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

Test #13:

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

input:

33333 99999

output:

133331
1 1
1 2
1 99998
1 99999
3 1
3 2
3 99998
3 99999
5 1
5 2
5 99998
5 99999
7 1
7 2
7 99998
7 99999
9 1
9 2
9 99998
9 99999
11 1
11 2
11 99998
11 99999
13 1
13 2
13 99998
13 99999
15 1
15 2
15 99998
15 99999
17 1
17 2
17 99998
17 99999
19 1
19 2
19 99998
19 99999
21 1
21 2
21 99998
21 99999
23 1
...

result:

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

Test #14:

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

input:

23342 98876

output:

122216
1 1
1 98876
2 1
2 98876
3 1
3 98876
4 1
4 98876
5 1
5 98876
6 1
6 98876
7 1
7 98876
8 1
8 98876
9 1
9 98876
10 1
10 98876
11 1
11 98876
12 1
12 98876
13 1
13 98876
14 1
14 98876
15 1
15 98876
16 1
16 98876
17 1
17 98876
18 1
18 98876
19 1
19 98876
20 1
20 98876
21 1
21 98876
22 1
22 98876
23 ...

result:

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

Test #15:

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

input:

56713 91234

output:

147946
1 1
1 2
1 91233
1 91234
3 1
3 2
3 91233
3 91234
5 1
5 2
5 91233
5 91234
7 1
7 2
7 91233
7 91234
9 1
9 2
9 91233
9 91234
11 1
11 2
11 91233
11 91234
13 1
13 2
13 91233
13 91234
15 1
15 2
15 91233
15 91234
17 1
17 2
17 91233
17 91234
19 1
19 2
19 91233
19 91234
21 1
21 2
21 91233
21 91234
23 1
...

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 99995
2 1
2 99995
3 1
3 99995
4 1
4 99995
5 1
5 99995
6 1
6 99995
7 1
7 99995
8 1
8 99995
9 1
9 99995
10 1
10 99995
11 1
11 99995
12 1
12 99995
13 1
13 99995
14 1
14 99995
15 1
15 99995
16 1
16 99995
17 1
17 99995
18 1
18 99995
19 1
19 99995
20 1
20 99995
21 1
21 99995
22 1
22 99995
23 ...

result:

ok n: 99995, m: 99995, bishops: 199988

Test #17:

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

input:

12345 54321

output:

66665
1 1
1 2
1 54320
1 54321
3 1
3 2
3 54320
3 54321
5 1
5 2
5 54320
5 54321
7 1
7 2
7 54320
7 54321
9 1
9 2
9 54320
9 54321
11 1
11 2
11 54320
11 54321
13 1
13 2
13 54320
13 54321
15 1
15 2
15 54320
15 54321
17 1
17 2
17 54320
17 54321
19 1
19 2
19 54320
19 54321
21 1
21 2
21 54320
21 54321
23 1
2...

result:

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

Test #18:

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

input:

90000 92000

output:

181998
1 1
1 92000
2 1
2 92000
3 1
3 92000
4 1
4 92000
5 1
5 92000
6 1
6 92000
7 1
7 92000
8 1
8 92000
9 1
9 92000
10 1
10 92000
11 1
11 92000
12 1
12 92000
13 1
13 92000
14 1
14 92000
15 1
15 92000
16 1
16 92000
17 1
17 92000
18 1
18 92000
19 1
19 92000
20 1
20 92000
21 1
21 92000
22 1
22 92000
23 ...

result:

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

Test #19:

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

input:

10000 70000

output:

79998
1 1
1 70000
2 1
2 70000
3 1
3 70000
4 1
4 70000
5 1
5 70000
6 1
6 70000
7 1
7 70000
8 1
8 70000
9 1
9 70000
10 1
10 70000
11 1
11 70000
12 1
12 70000
13 1
13 70000
14 1
14 70000
15 1
15 70000
16 1
16 70000
17 1
17 70000
18 1
18 70000
19 1
19 70000
20 1
20 70000
21 1
21 70000
22 1
22 70000
23 1...

result:

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

Test #20:

score: -100
Wrong Answer
time: 7ms
memory: 6740kb

input:

10000 70001

output:

80002
1 1
1 70001
2 1
2 70001
3 1
3 70001
4 1
4 70001
5 1
5 70001
6 1
6 70001
7 1
7 70001
8 1
8 70001
9 1
9 70001
10 1
10 70001
11 1
11 70001
12 1
12 70001
13 1
13 70001
14 1
14 70001
15 1
15 70001
16 1
16 70001
17 1
17 70001
18 1
18 70001
19 1
19 70001
20 1
20 70001
21 1
21 70001
22 1
22 70001
23 1...

result:

wrong answer Integer parameter [name=q] equals to 80002, violates the range [0, 80001]