結果

問題 No.1588 Connection
ユーザー 沙耶花沙耶花
提出日時 2021-07-08 22:46:04
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 4,049 ms
使用メモリ 22,680 KB
平均クエリ数 551.25
最終ジャッジ日時 2023-02-15 00:06:21
合計ジャッジ時間 7,231 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 22 ms
22,096 KB
testcase_01 AC 21 ms
21,744 KB
testcase_02 AC 22 ms
21,648 KB
testcase_03 AC 21 ms
22,252 KB
testcase_04 AC 22 ms
21,892 KB
testcase_05 AC 22 ms
21,768 KB
testcase_06 AC 24 ms
21,880 KB
testcase_07 AC 22 ms
21,760 KB
testcase_08 AC 24 ms
21,880 KB
testcase_09 AC 25 ms
22,540 KB
testcase_10 AC 25 ms
21,928 KB
testcase_11 AC 26 ms
21,980 KB
testcase_12 AC 54 ms
22,204 KB
testcase_13 AC 61 ms
21,916 KB
testcase_14 AC 22 ms
22,204 KB
testcase_15 AC 24 ms
21,892 KB
testcase_16 AC 22 ms
21,940 KB
testcase_17 AC 24 ms
21,980 KB
testcase_18 AC 22 ms
21,576 KB
testcase_19 AC 22 ms
22,516 KB
testcase_20 AC 24 ms
21,756 KB
testcase_21 AC 106 ms
21,868 KB
testcase_22 AC 102 ms
21,916 KB
testcase_23 AC 54 ms
22,420 KB
testcase_24 AC 40 ms
22,540 KB
testcase_25 AC 63 ms
22,432 KB
testcase_26 AC 62 ms
21,756 KB
testcase_27 AC 39 ms
21,992 KB
testcase_28 AC 34 ms
21,756 KB
testcase_29 AC 100 ms
22,680 KB
testcase_30 AC 100 ms
21,928 KB
testcase_31 AC 22 ms
21,892 KB
権限があれば一括ダウンロードができます

ソースコード

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