結果

問題 No.1588 Connection
ユーザー 夜
提出日時 2021-07-08 22:58:34
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 1,155 bytes
コンパイル時間 2,282 ms
コンパイル使用メモリ 97,948 KB
実行使用メモリ 24,336 KB
平均クエリ数 551.25
最終ジャッジ日時 2023-09-24 11:26:30
合計ジャッジ時間 3,914 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,024 KB
testcase_01 AC 23 ms
24,024 KB
testcase_02 AC 25 ms
24,300 KB
testcase_03 AC 24 ms
23,400 KB
testcase_04 AC 24 ms
23,604 KB
testcase_05 AC 22 ms
23,484 KB
testcase_06 AC 23 ms
24,336 KB
testcase_07 AC 23 ms
23,400 KB
testcase_08 AC 26 ms
23,628 KB
testcase_09 AC 26 ms
23,820 KB
testcase_10 AC 27 ms
23,340 KB
testcase_11 AC 25 ms
23,412 KB
testcase_12 AC 56 ms
24,324 KB
testcase_13 AC 60 ms
23,340 KB
testcase_14 AC 25 ms
24,012 KB
testcase_15 AC 25 ms
24,000 KB
testcase_16 AC 23 ms
24,012 KB
testcase_17 AC 24 ms
23,820 KB
testcase_18 AC 25 ms
24,336 KB
testcase_19 AC 24 ms
23,664 KB
testcase_20 AC 26 ms
23,616 KB
testcase_21 AC 100 ms
23,520 KB
testcase_22 AC 103 ms
23,652 KB
testcase_23 AC 56 ms
23,796 KB
testcase_24 AC 41 ms
24,012 KB
testcase_25 AC 68 ms
24,024 KB
testcase_26 AC 67 ms
23,796 KB
testcase_27 AC 42 ms
23,652 KB
testcase_28 AC 37 ms
24,036 KB
testcase_29 AC 103 ms
24,228 KB
testcase_30 AC 102 ms
23,988 KB
testcase_31 AC 23 ms
24,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int b[550][550] = { 0 };
int b1[4] = { 0,0,1,-1 };
int b2[4] = { 1,-1,0,0 };
int main() {
	long long n, m;
	cin >> n >> m;
	queue<pair<int, int>> que;
	que.push(make_pair(1, 1));
	b[1][1] = 1;
	while (!que.empty()) {
		int x = que.front().first, y = que.front().second;
		que.pop();
		for (int j = 0; j < 4; j++) {
			if (x + b1[j] == n && y + b2[j] == n) {
				cout << "Yes" << endl;
				return 0;
			}
			if (x + b1[j] <= 0 || x + b1[j] > n || y + b2[j] <= 0 || y + b2[j] > n)continue;
			if (b[x + b1[j]][y + b2[j]] == 0) {
				cout << x + b1[j] << " " << y + b2[j] << endl;
				string s;
				cin >> s;
				if (s == "-1") {
					return 0;
				}
				else if (s == "Black") {
				    b[x + b1[j]][y + b2[j]] = 1;
					que.push(make_pair(x + b1[j], y + b2[j]));
				}
				else {
					b[x + b1[j]][y + b2[j]] = -1;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}
0