結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,544 KB
testcase_01 AC 23 ms
23,868 KB
testcase_02 AC 23 ms
23,568 KB
testcase_03 AC 23 ms
23,580 KB
testcase_04 AC 23 ms
24,168 KB
testcase_05 AC 23 ms
23,352 KB
testcase_06 AC 24 ms
23,448 KB
testcase_07 AC 23 ms
24,252 KB
testcase_08 AC 28 ms
24,288 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 24 ms
23,544 KB
testcase_15 AC 24 ms
23,472 KB
testcase_16 AC 24 ms
23,316 KB
testcase_17 AC 24 ms
23,568 KB
testcase_18 AC 25 ms
24,288 KB
testcase_19 AC 25 ms
24,156 KB
testcase_20 AC 27 ms
23,976 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 58 ms
23,400 KB
testcase_24 AC 42 ms
24,168 KB
testcase_25 AC 27 ms
24,060 KB
testcase_26 AC 26 ms
23,688 KB
testcase_27 AC 43 ms
23,976 KB
testcase_28 AC 36 ms
24,276 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;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;
            cout<<nx+1<<' '<<ny+1<<endl;
            string s;cin>>s;
            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