結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
23,556 KB
testcase_01 AC 26 ms
23,508 KB
testcase_02 AC 26 ms
24,264 KB
testcase_03 AC 27 ms
23,316 KB
testcase_04 AC 27 ms
23,976 KB
testcase_05 AC 26 ms
24,180 KB
testcase_06 AC 28 ms
23,796 KB
testcase_07 AC 27 ms
24,264 KB
testcase_08 AC 29 ms
23,352 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 27 ms
24,348 KB
testcase_15 AC 27 ms
23,784 KB
testcase_16 AC 27 ms
24,240 KB
testcase_17 AC 26 ms
23,664 KB
testcase_18 AC 27 ms
23,340 KB
testcase_19 AC 27 ms
23,772 KB
testcase_20 AC 29 ms
23,952 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 57 ms
23,952 KB
testcase_24 AC 44 ms
23,988 KB
testcase_25 AC 30 ms
24,180 KB
testcase_26 AC 29 ms
23,352 KB
testcase_27 AC 44 ms
23,304 KB
testcase_28 AC 39 ms
23,628 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==2999){
                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