結果

問題 No.1588 Connection
ユーザー inksamuraiinksamurai
提出日時 2021-07-09 18:38:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,927 bytes
コンパイル時間 1,382 ms
コンパイル使用メモリ 132,448 KB
実行使用メモリ 36,048 KB
最終ジャッジ日時 2023-09-24 12:03:43
合計ジャッジ時間 7,742 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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<<"\n";
		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;
	};
	ok(0,0);
	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});
				// cout<<sz(que)<<"here\n";
			}
		}
	}
	cout<<"No\n";
/*
*/
	return 0;
}
0