結果

問題 No.1588 Connection
ユーザー kwm_tkwm_t
提出日時 2021-07-09 13:54:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,645 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 170,196 KB
実行使用メモリ 24,312 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-09-24 12:00:07
合計ジャッジ時間 4,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,472 KB
testcase_01 AC 22 ms
23,472 KB
testcase_02 AC 22 ms
23,736 KB
testcase_03 AC 23 ms
23,460 KB
testcase_04 AC 24 ms
23,724 KB
testcase_05 AC 22 ms
23,568 KB
testcase_06 AC 24 ms
23,952 KB
testcase_07 AC 24 ms
23,568 KB
testcase_08 AC 24 ms
24,240 KB
testcase_09 AC 26 ms
23,916 KB
testcase_10 AC 26 ms
23,304 KB
testcase_11 AC 27 ms
23,940 KB
testcase_12 AC 56 ms
23,928 KB
testcase_13 AC 60 ms
23,280 KB
testcase_14 AC 25 ms
24,312 KB
testcase_15 AC 24 ms
24,180 KB
testcase_16 AC 24 ms
23,604 KB
testcase_17 AC 24 ms
23,268 KB
testcase_18 AC 25 ms
23,736 KB
testcase_19 AC 25 ms
23,568 KB
testcase_20 AC 26 ms
23,988 KB
testcase_21 AC 106 ms
23,268 KB
testcase_22 AC 106 ms
23,448 KB
testcase_23 AC 58 ms
23,916 KB
testcase_24 AC 44 ms
23,616 KB
testcase_25 AC 67 ms
23,532 KB
testcase_26 AC 65 ms
23,544 KB
testcase_27 AC 42 ms
23,976 KB
testcase_28 AC 38 ms
23,532 KB
testcase_29 AC 101 ms
23,148 KB
testcase_30 AC 106 ms
23,316 KB
testcase_31 AC 24 ms
23,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
//const bool debug = false;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
//#define endl "\n"
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,-1,0,1 };
bool check[1001][1001];
bool used[1001][1001];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, m; cin >> n >> m;
	check[0][0] = true;
	used[0][0] = true;
	queue<P> q;
	q.push({ 0,0 });
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		rep(i, 4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if ((0 <= nx) && (n > nx) && (0 <= ny) && (n > ny)) {
				if (check[nx][ny])continue;
				cout << nx + 1 << " " << ny + 1 << endl;
				string s; cin >> s;
				if ("Black" == s) {
					used[nx][ny] = true;
					q.push({ nx,ny });
				}
				check[nx][ny] = true;
			}
		}
	}
	if (used[n - 1][n - 1])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
0