結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2021-07-08 23:04:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
QLE
(最初)
|
| 実行時間 | - |
| コード長 | 1,134 bytes |
| コンパイル時間 | 1,857 ms |
| コンパイル使用メモリ | 200,556 KB |
| 最終ジャッジ日時 | 2025-01-22 19:11:24 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 21 WA * 10 |
ソースコード
#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;
}
umezo