結果

問題 No.1588 Connection
ユーザー kotatsugamekotatsugame
提出日時 2021-07-08 22:51:55
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 425 ms
使用メモリ 22,608 KB
平均クエリ数 562.59
最終ジャッジ日時 2023-02-15 00:08:33
合計ジャッジ時間 3,749 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 21 ms
21,756 KB
testcase_01 AC 22 ms
21,980 KB
testcase_02 AC 22 ms
21,892 KB
testcase_03 AC 22 ms
21,868 KB
testcase_04 AC 21 ms
22,432 KB
testcase_05 AC 21 ms
22,552 KB
testcase_06 AC 23 ms
21,940 KB
testcase_07 AC 22 ms
22,252 KB
testcase_08 AC 25 ms
21,756 KB
testcase_09 AC 25 ms
22,252 KB
testcase_10 AC 26 ms
21,768 KB
testcase_11 AC 25 ms
22,252 KB
testcase_12 AC 57 ms
21,928 KB
testcase_13 AC 63 ms
21,916 KB
testcase_14 AC 22 ms
22,432 KB
testcase_15 AC 23 ms
22,588 KB
testcase_16 AC 22 ms
22,564 KB
testcase_17 AC 24 ms
22,432 KB
testcase_18 AC 23 ms
21,904 KB
testcase_19 AC 23 ms
22,432 KB
testcase_20 AC 23 ms
21,880 KB
testcase_21 AC 108 ms
21,756 KB
testcase_22 AC 108 ms
21,880 KB
testcase_23 AC 57 ms
21,916 KB
testcase_24 AC 41 ms
21,868 KB
testcase_25 AC 66 ms
21,892 KB
testcase_26 AC 64 ms
21,768 KB
testcase_27 AC 40 ms
21,916 KB
testcase_28 AC 35 ms
22,608 KB
testcase_29 AC 112 ms
21,904 KB
testcase_30 AC 111 ms
21,744 KB
testcase_31 AC 22 ms
22,216 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:27:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   27 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<cstdlib>
using namespace std;
int N,M;
int T[501][501];
bool ask(int x,int y)
{
	if(T[x][y])return T[x][y]==1;
	cout<<x<<" "<<y<<endl;
	string r;cin>>r;
	if(r=="-1")exit(1);
	T[x][y]=r=="Black"?1:-1;
	return T[x][y]==1;
}
int d[5]={0,1,0,-1};
bool vis[501][501];
void dfs(int x,int y)
{
	vis[x][y]=true;
	for(int r=0;r<4;r++)
	{
		int tx=x+d[r],ty=y+d[r+1];
		if(tx<1||ty<1||tx>N||ty>N||vis[tx][ty])continue;
		if(ask(tx,ty))dfs(tx,ty);
	}
}
main()
{
	cin>>N>>M;
	T[1][1]=T[N][N]=1;
	dfs(1,1);
	cout<<(vis[N][N]?"Yes":"No")<<endl;
}
0