結果
| 問題 | No.1588 Connection |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-12 10:57:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 107 ms / 2,000 ms |
| コード長 | 934 bytes |
| コンパイル時間 | 891 ms |
| コンパイル使用メモリ | 77,932 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 563.00 |
| 最終ジャッジ日時 | 2024-07-17 13:00:09 |
| 合計ジャッジ時間 | 4,172 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;
int r[509][509], dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
queue<pair<int, int> > q;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, m; cin >> n >> m;
q.push(make_pair(1, 1));
r[1][1] = 1;
while (!q.empty()) {
int y = q.front().first, x = q.front().second; q.pop();
for (int i = 0; i < 4; i++) {
int tx = x + dx[i], ty = y + dy[i];
if (tx < 1 || tx > n || ty < 1 || ty > n || r[ty][tx]) continue;
cout << ty << " " << tx << endl;
string s; cin >> s;
if (s[0] == 'B') {
r[ty][tx] = 1;
q.push(make_pair(ty, tx));
}
else
r[ty][tx] = -1;
}
}
if (r[n][n] == 1) cout << "Yes" << endl;
else cout << "No" << endl;
return 0;
}