結果

問題 No.1588 Connection
ユーザー ooaiu
提出日時 2025-07-12 09:03:14
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 3,218 ms
コンパイル使用メモリ 275,740 KB
実行使用メモリ 25,844 KB
平均クエリ数 647.66
最終ジャッジ日時 2025-07-12 09:03:21
合計ジャッジ時間 7,277 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int ask(int a, int b) {
	cout << a << " " << b << endl;
	string T;
	cin >> T;
	if(T == "Black") return 1;
	else if(T == "White") return 0;
	else exit(0);
}
int N, M;
int vis[505][505];
const int dx[] = {1, 0, -1, 0, 1};
void dfs(int x, int y) {
	vis[x][y] = 1;
	for(int r = 0; r < 4; r++) {
		int nx = x + dx[r], ny = y + dx[r+1];
		if(nx > N || ny > N || nx <= 0 || ny <= 0) continue;
		if(vis[nx][ny]) continue;
		if(ask(nx,ny)) dfs(nx,ny);
	}
}
int main() {
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	cin >> N >> M;
	dfs(1,1);
	cout << (vis[N][N] ? "Yes\n" : "No\n"); 
}
0