結果
問題 |
No.1588 Connection
|
ユーザー |
![]() |
提出日時 | 2021-07-09 09:59:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 2,144 ms |
コンパイル使用メモリ | 196,736 KB |
最終ジャッジ日時 | 2025-01-22 20:01:27 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | RE * 31 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pint = pair<int, int>; using pll = pair<ll, ll>; int N, M; vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1}; vector<vector<int>> grid; bool dfs(int h, int w){ if(h == N - 1 && w == N - 1)return true; for(int i = 0; i < 4; i++){ int nh = h + dx[i], nw = w + dy[i]; if(nh < 0 || nh > N - 1 || nw < 0 || nw > N - 1)continue; if(grid[nh][nw] != -1)continue; cout << nh << " " << nw << endl; string s; cin >> s; grid[nh][nw] = 1; if(s == "Black"){ if(dfs(nh, nw))return true; } } return false; } int main(){ cin >> N; cout << (dfs(0, 0) ? "Yes": "No") << endl; }