結果

問題 No.1588 Connection
ユーザー pockynypockyny
提出日時 2021-07-09 05:25:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 70,024 KB
実行使用メモリ 24,252 KB
平均クエリ数 564.00
最終ジャッジ日時 2023-09-24 11:57:21
合計ジャッジ時間 4,038 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
23,208 KB
testcase_01 AC 27 ms
23,484 KB
testcase_02 AC 27 ms
23,664 KB
testcase_03 AC 27 ms
23,640 KB
testcase_04 AC 26 ms
23,508 KB
testcase_05 AC 27 ms
24,240 KB
testcase_06 AC 29 ms
23,652 KB
testcase_07 AC 27 ms
23,676 KB
testcase_08 AC 29 ms
23,856 KB
testcase_09 AC 29 ms
23,556 KB
testcase_10 AC 30 ms
23,640 KB
testcase_11 AC 31 ms
24,084 KB
testcase_12 AC 60 ms
23,232 KB
testcase_13 AC 66 ms
23,460 KB
testcase_14 AC 28 ms
23,868 KB
testcase_15 AC 28 ms
23,688 KB
testcase_16 AC 27 ms
24,084 KB
testcase_17 AC 28 ms
23,580 KB
testcase_18 AC 27 ms
24,084 KB
testcase_19 AC 28 ms
24,084 KB
testcase_20 AC 29 ms
23,640 KB
testcase_21 AC 110 ms
23,272 KB
testcase_22 AC 112 ms
23,968 KB
testcase_23 AC 61 ms
24,252 KB
testcase_24 AC 46 ms
23,484 KB
testcase_25 AC 71 ms
23,676 KB
testcase_26 AC 69 ms
23,484 KB
testcase_27 AC 45 ms
23,484 KB
testcase_28 AC 39 ms
23,856 KB
testcase_29 AC 112 ms
23,436 KB
testcase_30 AC 111 ms
23,460 KB
testcase_31 AC 27 ms
24,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
bool used[1010][1010];
int mp[1010][1010];
int query(int a,int b){
    cout << a + 1 << " " << b + 1 << endl;
    string t; cin >> t;
    if(t[0]=='B') return 1;
    return 0;
}

void dfs(int x,int y,int n){
    if(used[x][y]) return;
    used[x][y] = true;
    int z = query(x,y);
    mp[x][y] = z;
    if(!mp[x][y]) return;
    if(x + 1<n) dfs(x + 1,y,n);
    if(x - 1>=0) dfs(x - 1,y,n);
    if(y + 1<n) dfs(x,y + 1,n);
    if(y - 1>=0) dfs(x,y - 1,n);
}

int main(){
    int i,j,n,m; cin >> n >> m;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) used[i][j] = false;
    }
    dfs(0,0,n);
    if(used[n - 1][n - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0