結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
risujiroh
|
| 提出日時 | 2021-07-08 23:01:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
QLE
(最初)
|
| 実行時間 | - |
| コード長 | 1,016 bytes |
| コンパイル時間 | 2,585 ms |
| コンパイル使用メモリ | 203,820 KB |
| 最終ジャッジ日時 | 2025-01-22 19:08:22 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 19 WA * 12 |
ソースコード
#include <bits/stdc++.h>
int main() {
using namespace std;
cin.tie(nullptr)->sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector a(n, vector<int>(n, -1));
a[0][0] = 1;
a[n - 1][n - 1] = 1;
auto query = [&](int i, int j) -> bool {
cout << i + 1 << ' ' << j + 1 << endl;
if (a[i][j] != -1) return a[i][j];
string s;
cin >> s;
return (a[i][j] = s[0] == 'b');
};
constexpr array di{1, 0, -1, 0};
constexpr array dj{0, 1, 0, -1};
vector visited(n, vector<bool>(n));
auto dfs = [&](auto self, int i, int j) -> void {
if (i == n - 1 && j == n - 1) {
cout << "Yes" << endl;
exit(0);
}
for (int d : {0, 1, 2, 3}) {
int ni = i + di[d];
int nj = j + dj[d];
if (min(ni, nj) < 0 || max(ni, nj) >= n || !query(i, j)) continue;
if (visited[ni][nj]) continue;
visited[ni][nj] = true;
self(self, ni, nj);
}
};
visited[0][0] = true;
dfs(dfs, 0, 0);
cout << "No" << endl;
}
risujiroh