結果

問題 No.1384 Bishop and Rook
ユーザー 沙耶花
提出日時 2021-02-07 21:28:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,355 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 197,668 KB
最終ジャッジ日時 2025-01-18 14:29:13
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other WA * 55
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
int N,M;
vector<pair<int,int>> ans;

/*
void go_r(){
	int y,x,yy;
	if(ans.back().first!=N){
		y = ans.back().first+1;
		
	}
	else{
		y = ans.back().first-1;
	}
	yy = ans.back().first;
	x = ans.back().second+1;
	ans.emplace_back(y,x);
	ans.emplace_back(yy,x);
}

void go_l(){
	int y,x,yy;
	if(ans.back().first!=N){
		y = ans.back().first+1;
		
	}
	else{
		y = ans.back().first-1;
	}
	yy = ans.back().first;
	x = ans.back().second-1;
	ans.emplace_back(y,x);
	ans.emplace_back(yy,x);
}

void go_d(){
	int y,x,yy,xx;
	if(ans.back().second!=M){
		x = ans.back().second+1;
		
	}
	else{
		x = ans.back().second-1;
	}
	xx = ans.back().second;
	y = ans.back().first+1;
	ans.emplace_back(y,x);
	ans.emplace_back(y,xx);
}
*/

int main(){
	
	int T;
	cin>>T;
	
	rep(_,T){
		
		cin>>N>>M;
		ans.resize(0);
		if(N==1&&M==1){
			ans.emplace_back(1,1);
		}
		if(N==2&&M==2){
			ans.emplace_back(1,1);
			ans.emplace_back(2,2);
			ans.emplace_back(2,1);
			ans.emplace_back(1,2);
		}
		
		if(ans.size()==0){
			cout<<-1<<endl;
			continue;
		}
		
		cout<<ans.size()-1<<endl;
		cout<<ans[0].first<<' '<<ans[0].second<<endl;
		rep(i,ans.size()){
			if(i==0)continue;
			cout<<ans[i].first<<' '<<ans[i].second<<endl;
		}
		
	}
	
	return 0;
}
0