結果

問題 No.1588 Connection
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-08 23:10:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 203,384 KB
実行使用メモリ 24,504 KB
平均クエリ数 562.59
最終ジャッジ日時 2023-09-24 11:33:27
合計ジャッジ時間 5,404 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,628 KB
testcase_01 AC 26 ms
24,348 KB
testcase_02 AC 25 ms
24,024 KB
testcase_03 AC 25 ms
24,372 KB
testcase_04 AC 26 ms
23,376 KB
testcase_05 AC 25 ms
24,084 KB
testcase_06 AC 26 ms
24,336 KB
testcase_07 AC 25 ms
23,640 KB
testcase_08 AC 28 ms
24,060 KB
testcase_09 AC 29 ms
23,628 KB
testcase_10 AC 30 ms
23,556 KB
testcase_11 AC 29 ms
23,544 KB
testcase_12 AC 59 ms
24,036 KB
testcase_13 AC 65 ms
23,424 KB
testcase_14 AC 26 ms
23,544 KB
testcase_15 AC 28 ms
24,060 KB
testcase_16 AC 26 ms
24,504 KB
testcase_17 AC 26 ms
23,640 KB
testcase_18 AC 26 ms
23,628 KB
testcase_19 AC 28 ms
23,844 KB
testcase_20 AC 29 ms
23,532 KB
testcase_21 AC 108 ms
23,532 KB
testcase_22 AC 106 ms
23,424 KB
testcase_23 AC 60 ms
23,412 KB
testcase_24 AC 45 ms
24,060 KB
testcase_25 AC 70 ms
24,036 KB
testcase_26 AC 68 ms
23,976 KB
testcase_27 AC 45 ms
23,640 KB
testcase_28 AC 39 ms
24,252 KB
testcase_29 AC 110 ms
23,400 KB
testcase_30 AC 114 ms
24,048 KB
testcase_31 AC 26 ms
23,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int N,M,d[500][500];
int f(int x,int y){
    if(d[x][y]==-1){
        if(x==N-1 && y==N-1){
            d[x][y]=0;
            return d[x][y];
        }
        cout<<x+1<<' '<<y+1<<endl;
        string S; cin>>S;
        if(S=="Black")d[x][y]=0;
        else d[x][y]=1;
    }
    return d[x][y];
}
signed main(){
    cin>>N>>M;
    fill(d[0],d[N],-1); d[0][0]=0;
    queue<int> Q; Q.push(0);
    for(int _=0;_<30000 && !Q.empty();_++){
        int x=Q.front()/N,y=Q.front()%N; Q.pop();
        for(int i=0;i<4;i++){
            int nx=x+dx[i],ny=y+dy[i];
            if(0<=nx && nx<N && 0<=ny && ny<N && d[nx][ny]==-1){
                int a=f(nx,ny);
                if(a==0)Q.push(nx*N+ny);
            }
        }
    }
    if(d[N-1][N-1])puts("No");
    else puts("Yes");
}
0