結果

問題 No.1588 Connection
ユーザー umezoumezo
提出日時 2021-07-08 23:04:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,134 bytes
コンパイル時間 2,116 ms
コンパイル使用メモリ 204,776 KB
実行使用メモリ 24,480 KB
平均クエリ数 559.00
最終ジャッジ日時 2023-09-24 11:31:06
合計ジャッジ時間 5,437 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
24,168 KB
testcase_01 AC 26 ms
23,940 KB
testcase_02 AC 26 ms
24,048 KB
testcase_03 AC 26 ms
23,952 KB
testcase_04 AC 26 ms
23,520 KB
testcase_05 AC 26 ms
23,940 KB
testcase_06 AC 27 ms
23,640 KB
testcase_07 AC 26 ms
23,616 KB
testcase_08 AC 29 ms
24,324 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 26 ms
23,652 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 26 ms
23,652 KB
testcase_15 AC 28 ms
23,844 KB
testcase_16 AC 26 ms
24,372 KB
testcase_17 AC 27 ms
23,388 KB
testcase_18 AC 26 ms
23,364 KB
testcase_19 AC 27 ms
24,372 KB
testcase_20 AC 29 ms
24,384 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 69 ms
23,652 KB
testcase_26 AC 67 ms
23,352 KB
testcase_27 AC 44 ms
24,300 KB
testcase_28 AC 39 ms
23,628 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 26 ms
23,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
 
#include<bits/stdc++.h>
using namespace std;

int A[510][510];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int n,m;
  cin>>n>>m;
  
  if(m<2*n-1){
    cout<<"No"<<endl;
    return 0;
  }
  if(m>=n*n-1){
    cout<<"Yes"<<endl;
    return 0;
  }
  
  A[1][1]=1,A[n][n]=1;
  queue<pair<int,int>> q;
  q.push({1,1});
  int cnt=0;
  while(!q.empty()){
    auto t=q.front();
    q.pop();
    int y=t.first,x=t.second;
    rep(i,4){
      int ny=y+dy[i],nx=x+dx[i];
      if(ny<1 || ny>n || nx<1 || nx>n) continue;
      if(A[ny][nx]>0) continue;
      cout<<ny<<" "<<nx<<endl;
      cnt++;
      string t;
      cin>>t;
      if(t=="Black"){
        A[ny][nx]=1;
        q.push({ny,nx});
        if((ny==1 && nx==0) || (ny==0 && nx==1)){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
      else if(t=="White"){
        A[ny][nx]=2;
      }
      else if(t=="-1") return 0;
    }
    if(cnt>=3000) break;
  }
  cout<<"No"<<endl;

  return 0;
}
0