結果

問題 No.1588 Connection
ユーザー chestnut_68chestnut_68
提出日時 2021-07-08 23:36:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,220 bytes
コンパイル時間 3,993 ms
コンパイル使用メモリ 235,468 KB
実行使用メモリ 24,492 KB
平均クエリ数 1.94
最終ジャッジ日時 2023-09-24 11:42:36
合計ジャッジ時間 11,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
23,520 KB
testcase_01 RE -
testcase_02 AC 24 ms
23,484 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
権限があれば一括ダウンロードができます

ソースコード

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==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