結果
| 問題 | No.1588 Connection | 
| コンテスト | |
| ユーザー |  kuc_jackson | 
| 提出日時 | 2021-07-09 10:02:05 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 780 bytes | 
| コンパイル時間 | 2,274 ms | 
| コンパイル使用メモリ | 197,160 KB | 
| 最終ジャッジ日時 | 2025-01-22 20:02:00 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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 + 1 << " " << nw + 1 << endl;
        string s;
        cin >> s;
        grid[nh][nw] = 1;
        if(s == "Black"){
            if(dfs(nh, nw))return true;
        }
    }
    return false;
}
int main(){
    cin >> N >> M;
    cout << (dfs(0, 0) ? "Yes": "No") << endl;
}
            
            
            
        