結果

問題 No.1588 Connection
ユーザー 沙耶花
提出日時 2021-07-08 22:46:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 259,312 KB
最終ジャッジ日時 2025-01-22 18:55:02
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001



int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector f(N,vector<bool>(N,false));
	f[0][0] = true;
	f.back().back() = true;
	
	queue<pair<int,int>> Q;
	Q.emplace(0,0);
	vector ff(N,vector<bool>(N,false));
	ff[0][0] = true;
	vector dx = {1,-1,0,0},dy = {0,0,1,-1};
	while(Q.size()>0){
		int y = Q.front().first,x = Q.front().second;
		Q.pop();
		
		rep(i,4){
			int yy = y+dy[i],xx = x+dx[i];
			if(yy==N-1&&xx==N-1){
				cout<<"Yes"<<endl;
				return 0;
			}
			if(yy>=N||xx>=N||xx<0||yy<0)continue;
			if(ff[yy][xx])continue;
			ff[yy][xx] = true;
			cout<<yy+1<<' '<<xx+1<<endl;
			
			string ret;
			cin>>ret;
			if(ret=="Black"){
				f[yy][xx] = true;
				Q.emplace(yy,xx);
			}
		}
		
	}
	
	
	cout<<"No"<<endl;
	
	return 0;
}
0