QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#173604#7178. Bishopsucup-team139#WA 21ms5300kbC++231.9kb2023-09-10 00:31:072023-09-10 00:31:07

Judging History

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

  • [2023-09-10 00:31:07]
  • 评测
  • 测评结果:WA
  • 用时:21ms
  • 内存:5300kb
  • [2023-09-10 00:31:07]
  • 提交

answer

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

vector<pair<int,int>> sol;
int n,m;

void check(int n,bool flg){
    if(n==0)return;
    
    bool tolto=false;
    if(n%2==0)n--,tolto=true;
    
    for(int i=1;i<=n;i+=2){
        sol.push_back({i+flg,1});
    }
    
    for(int i=1+(m%2==0);i<=n;i+=2){
        if((i!=1 && i!=n) || n!=m){
            sol.push_back({i+flg,m});
        }
    }
    
    int tmp = (n+1)/2;
    if(n%4==1){
        int last = (m%2==1 ? m-tmp+1 : m-tmp+1+1);
        
        if(m%2==0){
            if(flg){
                sol.push_back({1,m});
                last=min(last,m-tmp);
            }
            
            if(tolto){
                sol.push_back({n+1,m});
                last=min(last,m-tmp);
            }
        }
        
        for(int i=tmp+2;i<last;i+=2){
            sol.push_back({tmp+flg,i});
        }
    }else{
        
        int last = (m%2==1 ? m-tmp+1 : m-tmp+1+1);
        
        if(m%2==0){
            if(flg){
                sol.push_back({1,m});
                last=min(last,m-tmp);
            }
            
            if(tolto){
                sol.push_back({n+1,m});
                last=min(last,m-tmp);
            }
        }
        
        for(int i=tmp+2;i<last;i+=2){
            sol.push_back({tmp+flg,i});
        }
    }
}

void solve(int t){
    cin>>n>>m;
    
    bool inv = false;
    
    if(n>m){
        swap(n,m);
        inv=true;
    }
    
    check(n,false);
    check(n-1,true);
    
    assert(sol.size()==n+m-1 || n==m);
    
    cout<<sol.size()<<"\n";
    for(auto [x,y] : sol){
        if(inv)swap(x,y);
        cout<<x<<" "<<y<<"\n";
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)solve(i);
    
    return 0;
}

详细

Test #1:

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

input:

2 5

output:

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

result:

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

Test #2:

score: 0
Accepted
time: 1ms
memory: 3664kb

input:

5 5

output:

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

result:

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

Test #3:

score: -100
Wrong Answer
time: 21ms
memory: 5300kb

input:

100000 100000

output:

200000
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 1
...

result:

wrong answer Sum diagonals are not distinct