結果
問題 |
No.1384 Bishop and Rook
|
ユーザー |
![]() |
提出日時 | 2021-01-16 20:59:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,297 ms / 2,000 ms |
コード長 | 1,813 bytes |
コンパイル時間 | 1,600 ms |
コンパイル使用メモリ | 169,648 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 23:24:33 |
合計ジャッジ時間 | 17,029 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define pb push_back int main(){ int t; cin>>t; while(t--){ int n,m; cin>>n>>m; if(n==1&&m==1){ cout<<"0"<<endl; cout<<"1 1"<<endl; } else if(n%2==0&&m%2==0){ cout<<n*m-1<<endl; int nowi=1,nowj=1; for(int i=0;i<(n*m)/4;i++){ if(nowi%2==1){ if(nowj!=m/2){ cout<<nowi*2-1<<" "<<nowj*2-1<<endl; cout<<nowi*2<<" "<<nowj*2<<endl; cout<<nowi*2<<" "<<nowj*2-1<<endl; cout<<nowi*2-1<<" "<<nowj*2<<endl; nowj+=1; } else{ cout<<nowi*2-1<<" "<<nowj*2-1<<endl; cout<<nowi*2<<" "<<nowj*2<<endl; cout<<nowi*2-1<<" "<<nowj*2<<endl; cout<<nowi*2<<" "<<nowj*2-1<<endl; nowi+=1; } } else{ if(nowj==m/2){ cout<<nowi*2-1<<" "<<nowj*2-1<<endl; cout<<nowi*2<<" "<<nowj*2<<endl; cout<<nowi*2-1<<" "<<nowj*2<<endl; cout<<nowi*2<<" "<<nowj*2-1<<endl; if(nowj==1){ nowi+=1; } else{ nowj-=1; } } else if(nowj!=1){ cout<<nowi*2<<" "<<nowj*2<<endl; cout<<nowi*2-1<<" "<<nowj*2-1<<endl; cout<<nowi*2-1<<" "<<nowj*2<<endl; cout<<nowi*2<<" "<<nowj*2-1<<endl; nowj-=1; } else{ cout<<nowi*2<<" "<<nowj*2<<endl; cout<<nowi*2-1<<" "<<nowj*2-1<<endl; cout<<nowi*2-1<<" "<<nowj*2<<endl; cout<<nowi*2<<" "<<nowj*2-1<<endl; nowi+=1; } } } } else{ cout<<-1<<endl; } } }