結果

問題 No.1588 Connection
ユーザー shiomusubi496shiomusubi496
提出日時 2021-07-08 23:10:46
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 1,766 ms
使用メモリ 22,844 KB
平均クエリ数 562.59
最終ジャッジ日時 2023-02-15 01:05:48
合計ジャッジ時間 4,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 19 ms
22,844 KB
testcase_01 AC 18 ms
22,240 KB
testcase_02 AC 18 ms
21,904 KB
testcase_03 AC 18 ms
22,564 KB
testcase_04 AC 19 ms
22,264 KB
testcase_05 AC 19 ms
21,748 KB
testcase_06 AC 19 ms
21,756 KB
testcase_07 AC 18 ms
21,756 KB
testcase_08 AC 20 ms
21,968 KB
testcase_09 AC 22 ms
21,892 KB
testcase_10 AC 21 ms
22,432 KB
testcase_11 AC 21 ms
21,868 KB
testcase_12 AC 50 ms
21,928 KB
testcase_13 AC 56 ms
21,892 KB
testcase_14 AC 19 ms
21,880 KB
testcase_15 AC 19 ms
21,784 KB
testcase_16 AC 20 ms
22,552 KB
testcase_17 AC 20 ms
21,880 KB
testcase_18 AC 19 ms
21,812 KB
testcase_19 AC 21 ms
21,756 KB
testcase_20 AC 23 ms
21,880 KB
testcase_21 AC 97 ms
21,744 KB
testcase_22 AC 95 ms
21,756 KB
testcase_23 AC 49 ms
22,608 KB
testcase_24 AC 36 ms
22,432 KB
testcase_25 AC 59 ms
22,240 KB
testcase_26 AC 58 ms
21,768 KB
testcase_27 AC 36 ms
22,552 KB
testcase_28 AC 30 ms
22,444 KB
testcase_29 AC 101 ms
21,916 KB
testcase_30 AC 101 ms
22,832 KB
testcase_31 AC 19 ms
22,576 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