結果

問題 No.1588 Connection
ユーザー kotatsugamekotatsugame
提出日時 2021-07-08 22:51:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 561 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 64,884 KB
実行使用メモリ 24,360 KB
平均クエリ数 562.59
最終ジャッジ日時 2023-09-24 10:49:48
合計ジャッジ時間 3,715 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
24,036 KB
testcase_01 AC 25 ms
23,844 KB
testcase_02 AC 25 ms
24,348 KB
testcase_03 AC 25 ms
23,532 KB
testcase_04 AC 25 ms
23,640 KB
testcase_05 AC 25 ms
23,808 KB
testcase_06 AC 25 ms
23,364 KB
testcase_07 AC 25 ms
23,388 KB
testcase_08 AC 27 ms
24,048 KB
testcase_09 AC 28 ms
23,376 KB
testcase_10 AC 28 ms
24,036 KB
testcase_11 AC 29 ms
23,556 KB
testcase_12 AC 59 ms
23,808 KB
testcase_13 AC 64 ms
23,544 KB
testcase_14 AC 25 ms
24,348 KB
testcase_15 AC 27 ms
23,532 KB
testcase_16 AC 25 ms
24,036 KB
testcase_17 AC 25 ms
24,336 KB
testcase_18 AC 25 ms
24,336 KB
testcase_19 AC 25 ms
23,556 KB
testcase_20 AC 26 ms
24,336 KB
testcase_21 AC 110 ms
23,544 KB
testcase_22 AC 110 ms
24,360 KB
testcase_23 AC 59 ms
23,808 KB
testcase_24 AC 44 ms
24,012 KB
testcase_25 AC 69 ms
23,388 KB
testcase_26 AC 68 ms
23,652 KB
testcase_27 AC 43 ms
24,000 KB
testcase_28 AC 38 ms
23,664 KB
testcase_29 AC 110 ms
24,348 KB
testcase_30 AC 110 ms
24,348 KB
testcase_31 AC 26 ms
23,412 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