結果

問題 No.1588 Connection
ユーザー chestnut_68chestnut_68
提出日時 2021-07-08 23:42:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,384 bytes
コンパイル時間 3,921 ms
コンパイル使用メモリ 235,836 KB
実行使用メモリ 24,408 KB
平均クエリ数 297.78
最終ジャッジ日時 2023-09-24 11:45:07
合計ジャッジ時間 6,648 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,352 KB
testcase_01 AC 24 ms
23,460 KB
testcase_02 AC 24 ms
23,556 KB
testcase_03 AC 24 ms
23,772 KB
testcase_04 AC 24 ms
24,048 KB
testcase_05 AC 25 ms
23,472 KB
testcase_06 AC 25 ms
24,084 KB
testcase_07 AC 24 ms
24,264 KB
testcase_08 AC 26 ms
23,592 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 28 ms
23,940 KB
testcase_15 AC 28 ms
24,408 KB
testcase_16 AC 25 ms
23,556 KB
testcase_17 AC 26 ms
23,964 KB
testcase_18 AC 26 ms
24,072 KB
testcase_19 AC 26 ms
24,228 KB
testcase_20 AC 28 ms
23,976 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 56 ms
23,436 KB
testcase_24 AC 41 ms
23,400 KB
testcase_25 AC 27 ms
23,976 KB
testcase_26 AC 27 ms
23,676 KB
testcase_27 AC 42 ms
23,844 KB
testcase_28 AC 37 ms
23,352 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD=1e9+7;
const long long INF = 1LL<<60;
void YN(bool x){
  if(x) cout<<"Yes";
  else cout<<"No";
}
int dx[]={1,0,0,-1},dy[]={0,1,-1,0};
int main(){
    int N,M,C=0;cin>>N>>M;
    M-=2;
    vector<vector<int>> D(N,vector<int>(N,-1));
    D[0][0]=0;
    vector<vector<char>> S(N,vector<char>(N,'G'));
    S[0][0]='B';
    queue<pair<int,int>>q;
    q.push({0,0});
    while(q.size()){
        auto x=q.front().first,y=q.front().second;
        q.pop();
        if(N-1-x+N-1+y-1>M)continue;
        rep(i,4){
            auto nx=x+dx[i],ny=y+dy[i];
            if(nx<0||ny<0||nx>=N||ny>=N)continue;
            if(nx==N-1&&ny==N-1){
                cout<<"Yes";
                return 0;
            }
            if(S[nx][ny]!='G')continue;
            if(C==3000){
                cout<<"No";
                return 0;
            }
            cout<<nx+1<<' '<<ny+1<<endl;
            string s;cin>>s;
            C++;
            if(s=="-1"){
                cout<<"No";
                return 0;
            }
            if(s=="Black"){
                S[nx][ny]='B';
                q.push({nx,ny});
                M--;
            }
            else S[nx][ny]='W';
        }
    }
    cout<<"No";
    
}
0