結果
| 問題 |
No.1384 Bishop and Rook
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-07 22:20:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,417 ms / 2,000 ms |
| コード長 | 886 bytes |
| コンパイル時間 | 544 ms |
| コンパイル使用メモリ | 67,328 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-04 16:06:09 |
| 合計ジャッジ時間 | 17,619 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 55 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int T,N,M;
main()
{
cin>>T;
for(;T--;)
{
cin>>N>>M;
if(N%2!=0||M%2!=0)
{
if(N==1&&M==1)
{
cout<<0<<endl<<"1 1"<<endl;
continue;
}
cout<<-1<<endl;
continue;
}
cout<<N*M-1<<endl;
for(int j=1;j<M;j+=2)
{
if(j/2%2==0)
{
for(int i=1;i+2<N;i+=2)
{
cout<<i<<" "<<j<<endl;
cout<<i+1<<" "<<j+1<<endl;
cout<<i<<" "<<j+1<<endl;
cout<<i+1<<" "<<j<<endl;
}
cout<<N-1<<" "<<j<<endl;
cout<<N<<" "<<j+1<<endl;
cout<<N<<" "<<j<<endl;
cout<<N-1<<" "<<j+1<<endl;
}
else
{
cout<<N-1<<" "<<j<<endl;
cout<<N<<" "<<j+1<<endl;
cout<<N<<" "<<j<<endl;
cout<<N-1<<" "<<j+1<<endl;
for(int i=N-3;i>0;i-=2)
{
cout<<i+1<<" "<<j+1<<endl;
cout<<i<<" "<<j<<endl;
cout<<i+1<<" "<<j<<endl;
cout<<i<<" "<<j+1<<endl;
}
}
}
}
}