結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 17:05:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 1,329 bytes |
| コンパイル時間 | 1,941 ms |
| コンパイル使用メモリ | 181,292 KB |
| 実行使用メモリ | 25,476 KB |
| 平均クエリ数 | 563.00 |
| 最終ジャッジ日時 | 2024-07-17 12:57:33 |
| 合計ジャッジ時間 | 5,153 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n); i >= 0; i--)
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = (a); i >= (int)(n); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using P = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int N, M;
vector<vector<bool>> seen, masu;
queue<P> Q;
int main() {
cin >> N >> M;
seen.assign(N+1,vector<bool>(N+1));
masu.assign(N+1,vector<bool>(N+1));
Q.push({1,1});
seen[1][1] = true;
masu[1][1] = true;
while(Q.size()) {
int px, py;
tie(px, py) = Q.front(); Q.pop();
REP(i,4) {
int ex = px + dx[i], ey = py + dy[i];
if(ex <= 0 || ey <= 0 || ex > N || ey > N) continue;
if(seen[ex][ey]) continue;
cout << ex << " " << ey << endl;
string nxt; cin >> nxt;
if(nxt == "Black") {
masu[ex][ey] = true;
Q.push({ex,ey});
}
seen[ex][ey] = true;
}
}
cout << (masu[N][N] ? "Yes" : "No") << endl;
return 0;
}