結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
inksamurai
|
| 提出日時 | 2021-07-09 18:41:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
(最新)
QLE
(最初)
|
| 実行時間 | - |
| コード長 | 1,913 bytes |
| コンパイル時間 | 1,185 ms |
| コンパイル使用メモリ | 115,432 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 3.00 |
| 最終ジャッジ日時 | 2024-07-17 12:59:10 |
| 合計ジャッジ時間 | 3,839 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 19 WA * 12 |
ソースコード
#include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip>
#include <stdio.h>
#include <assert.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++)
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(int i = x ; i < n ; i++)
#define vi vector <int>
#define vec(...) vector<__VA_ARGS__>
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
using namespace std;
const int max_n = 103002;
const int di[]={1,-1,0,0};
const int dj[]={0,0,1,-1};
int main(){
fcin;
int n,m;
cin>>n>>m;
vec(vi) a(n,vi(n,-1));
a[0][0]=a[n-1][n-1]=1;
queue<pii> que;
que.push({0,0});
function<void(int,int)> ask = [&](int x,int y){
cout<<x+1<<" "<<y+1<<endl;
string s;
cin>>s;
if(s=="Black") a[x][y]=1;
else a[x][y]=0;
return;
};
auto ok = [&](int x,int y){
bool pok=0;
if(min(x,y)<0) return pok;
if(max(x,y)>=n) return pok;
return pok=1;
};
while(sz(que)){
pii p = que.front();
que.pop();
if(p.fi==n-1 and p.se==n-1){
cout<<"Yes\n";
exit(0);
}
rep(i,4){
int nex=p.fi+di[i],ney=p.se+dj[i];
if(!ok(nex,ney)) continue;
if(a[nex][ney]==0) continue;
if(a[nex][ney]==-1) ask(nex,ney);
if(a[nex][ney]==1){
que.push({nex,ney});
}
}
while(sz(que)) que.pop();
}
cout<<"No\n";
/*
*/
return 0;
}
inksamurai