結果

問題 No.1588 Connection
ユーザー inksamuraiinksamurai
提出日時 2021-07-09 18:41:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,913 bytes
コンパイル時間 1,080 ms
コンパイル使用メモリ 111,464 KB
実行使用メモリ 24,540 KB
平均クエリ数 3.00
最終ジャッジ日時 2023-09-24 12:04:09
合計ジャッジ時間 3,693 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
24,252 KB
testcase_01 WA -
testcase_02 AC 23 ms
23,568 KB
testcase_03 AC 24 ms
24,048 KB
testcase_04 AC 23 ms
23,544 KB
testcase_05 AC 24 ms
24,324 KB
testcase_06 AC 23 ms
24,060 KB
testcase_07 AC 23 ms
23,712 KB
testcase_08 AC 24 ms
23,448 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 27 ms
24,396 KB
testcase_15 AC 25 ms
24,060 KB
testcase_16 AC 26 ms
23,676 KB
testcase_17 AC 27 ms
23,688 KB
testcase_18 AC 27 ms
24,384 KB
testcase_19 AC 27 ms
23,556 KB
testcase_20 AC 29 ms
24,408 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 28 ms
23,856 KB
testcase_26 AC 28 ms
23,556 KB
testcase_27 AC 25 ms
23,664 KB
testcase_28 AC 24 ms
23,436 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0