QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468910#7178. Bishopsembusca#WA 17ms3712kbC++20965b2024-07-09 02:46:462024-07-09 02:46:48

Judging History

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

  • [2024-07-09 02:46:48]
  • 评测
  • 测评结果:WA
  • 用时:17ms
  • 内存:3712kb
  • [2024-07-09 02:46:46]
  • 提交

answer


#include "bits/stdc++.h"
using namespace std;

#define endl '\n'
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
 


int main() {
    cin.tie(0)->sync_with_stdio(0);
    ll n, m; cin>>n>>m;
    ll ma=-1;
    int qual=0,p=0,p2=0;

    for(ll i=1;i<=n;i++){
        if(ma<((((m-1)/i)+1)*i)){
            ma=(((m-1)/i)+1)*i;
            qual=1;
            p=i;
            p2=m;
        }
    }
    for(ll i=1;i<=m;i++){
        if(ma<((((n-1)/i)+1)*i)){
            ma=(((n-1)/i)+1)*i;
            qual=0;
            p=i;
            p2=n;
        }
    }
    cout<<ma<<'\n';
    for(int i=p2;i>0;i-=p){
        for(int u=1;u<=p;u++){
            if(!qual){
                cout<<i<<" "<<u<<'\n';
            }
            else{
                cout<<u<<" "<<i<<'\n';
            }
        }
    }
    


    return 0;
}

詳細信息

Test #1:

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

input:

2 5

output:

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

result:

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

Test #2:

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

input:

5 5

output:

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

result:

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

Test #3:

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

input:

100000 100000

output:

199998
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 100000
31...

result:

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

Test #4:

score: 0
Accepted
time: 17ms
memory: 3652kb

input:

100000 99999

output:

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

Test #5:

score: -100
Wrong Answer
time: 8ms
memory: 3652kb

input:

100000 50000

output:

149997
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:

wrong answer Participant's answer is not optimal (149997 < 149998)