結果

問題 No.1588 Connection
ユーザー e869120e869120
提出日時 2021-07-08 22:04:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 76,192 KB
実行使用メモリ 24,420 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-09-24 10:43:19
合計ジャッジ時間 3,675 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,388 KB
testcase_01 AC 22 ms
23,376 KB
testcase_02 AC 25 ms
23,388 KB
testcase_03 AC 23 ms
23,652 KB
testcase_04 AC 24 ms
23,424 KB
testcase_05 AC 23 ms
24,336 KB
testcase_06 AC 24 ms
24,396 KB
testcase_07 AC 24 ms
24,384 KB
testcase_08 AC 26 ms
23,640 KB
testcase_09 AC 27 ms
24,384 KB
testcase_10 AC 27 ms
23,688 KB
testcase_11 AC 28 ms
23,520 KB
testcase_12 AC 55 ms
23,664 KB
testcase_13 AC 62 ms
23,820 KB
testcase_14 AC 24 ms
24,372 KB
testcase_15 AC 26 ms
23,604 KB
testcase_16 AC 25 ms
24,024 KB
testcase_17 AC 26 ms
23,616 KB
testcase_18 AC 24 ms
23,832 KB
testcase_19 AC 24 ms
24,360 KB
testcase_20 AC 26 ms
23,820 KB
testcase_21 AC 101 ms
24,048 KB
testcase_22 AC 107 ms
23,376 KB
testcase_23 AC 58 ms
23,604 KB
testcase_24 AC 41 ms
23,364 KB
testcase_25 AC 66 ms
23,808 KB
testcase_26 AC 65 ms
23,640 KB
testcase_27 AC 43 ms
23,832 KB
testcase_28 AC 36 ms
24,420 KB
testcase_29 AC 105 ms
24,036 KB
testcase_30 AC 109 ms
23,388 KB
testcase_31 AC 24 ms
23,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <cassert>
using namespace std;

int N, M;
bool used[1009][1009], shirabeta[1009][1009];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0,-1 };
queue<pair<int, int>> Q;

int main() {
	cin >> N >> M;
	assert(2 <= N && N <= 500);
	assert(2 <= M && M <= 1000);
	used[1][1] = true; shirabeta[1][1] = true; Q.push(make_pair(1, 1));

	while (!Q.empty()) {
		int px = Q.front().first, py = Q.front().second; Q.pop();
		for (int i = 0; i < 4; i++) {
			int ex = px + dx[i], ey = py + dy[i];
			if (ex <= 0 || ex > N || ey <= 0 || ey > N) continue;
			if (shirabeta[ex][ey] == true) continue;
			cout << ex << " " << ey << endl;
			string str; cin >> str;
			if (str == "Black") { used[ex][ey] = true; Q.push(make_pair(ex, ey)); }
			assert(str != "-1");
			shirabeta[ex][ey] = true;
		}
	}

	if (used[N][N] == true) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
0