結果

問題 No.1384 Bishop and Rook
ユーザー kotatsugamekotatsugame
提出日時 2021-02-07 22:20:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,422 ms / 2,000 ms
コード長 886 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 67,300 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 22:26:02
合計ジャッジ時間 18,442 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 800 ms
4,376 KB
testcase_02 AC 369 ms
4,380 KB
testcase_03 AC 145 ms
4,376 KB
testcase_04 AC 207 ms
4,376 KB
testcase_05 AC 547 ms
4,376 KB
testcase_06 AC 734 ms
4,380 KB
testcase_07 AC 851 ms
4,380 KB
testcase_08 AC 673 ms
4,376 KB
testcase_09 AC 17 ms
4,380 KB
testcase_10 AC 455 ms
4,380 KB
testcase_11 AC 11 ms
4,380 KB
testcase_12 AC 21 ms
4,380 KB
testcase_13 AC 13 ms
4,376 KB
testcase_14 AC 1,142 ms
4,376 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 1,378 ms
4,380 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 23 ms
4,376 KB
testcase_19 AC 1,101 ms
4,380 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 36 ms
4,380 KB
testcase_22 AC 35 ms
4,376 KB
testcase_23 AC 30 ms
4,376 KB
testcase_24 AC 36 ms
4,380 KB
testcase_25 AC 37 ms
4,376 KB
testcase_26 AC 33 ms
4,376 KB
testcase_27 AC 33 ms
4,376 KB
testcase_28 AC 32 ms
4,380 KB
testcase_29 AC 35 ms
4,380 KB
testcase_30 AC 30 ms
4,376 KB
testcase_31 AC 23 ms
4,380 KB
testcase_32 AC 29 ms
4,376 KB
testcase_33 AC 29 ms
4,376 KB
testcase_34 AC 27 ms
4,380 KB
testcase_35 AC 28 ms
4,376 KB
testcase_36 AC 20 ms
4,376 KB
testcase_37 AC 19 ms
4,376 KB
testcase_38 AC 18 ms
4,376 KB
testcase_39 AC 18 ms
4,380 KB
testcase_40 AC 21 ms
4,380 KB
testcase_41 AC 140 ms
4,376 KB
testcase_42 AC 130 ms
4,380 KB
testcase_43 AC 156 ms
4,376 KB
testcase_44 AC 179 ms
4,380 KB
testcase_45 AC 177 ms
4,376 KB
testcase_46 AC 144 ms
4,376 KB
testcase_47 AC 160 ms
4,376 KB
testcase_48 AC 153 ms
4,376 KB
testcase_49 AC 87 ms
4,376 KB
testcase_50 AC 89 ms
4,376 KB
testcase_51 AC 4 ms
4,376 KB
testcase_52 AC 1,422 ms
4,376 KB
testcase_53 AC 574 ms
4,380 KB
testcase_54 AC 5 ms
4,380 KB
testcase_55 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:4:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    4 | main()
      | ^~~~

ソースコード

diff #

#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;
				}
			}
		}
	}
}
0