結果

問題 No.1588 Connection
ユーザー pockynypockyny
提出日時 2021-07-08 23:11:07
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 526 ms
使用メモリ 24,636 KB
平均クエリ数 564.00
最終ジャッジ日時 2023-02-15 01:05:36
合計ジャッジ時間 3,538 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 20 ms
21,880 KB
testcase_01 AC 21 ms
22,564 KB
testcase_02 AC 20 ms
21,928 KB
testcase_03 AC 19 ms
21,880 KB
testcase_04 AC 20 ms
21,880 KB
testcase_05 AC 21 ms
21,992 KB
testcase_06 AC 21 ms
21,992 KB
testcase_07 AC 20 ms
21,892 KB
testcase_08 AC 22 ms
21,768 KB
testcase_09 AC 23 ms
22,252 KB
testcase_10 AC 23 ms
21,880 KB
testcase_11 AC 22 ms
21,892 KB
testcase_12 AC 50 ms
21,636 KB
testcase_13 AC 56 ms
21,928 KB
testcase_14 AC 20 ms
22,240 KB
testcase_15 AC 21 ms
22,204 KB
testcase_16 AC 21 ms
21,980 KB
testcase_17 AC 20 ms
22,692 KB
testcase_18 AC 20 ms
21,968 KB
testcase_19 AC 20 ms
22,124 KB
testcase_20 AC 22 ms
22,160 KB
testcase_21 AC 96 ms
24,636 KB
testcase_22 AC 97 ms
24,512 KB
testcase_23 AC 50 ms
22,924 KB
testcase_24 AC 36 ms
22,432 KB
testcase_25 AC 58 ms
23,104 KB
testcase_26 AC 56 ms
23,108 KB
testcase_27 AC 36 ms
22,508 KB
testcase_28 AC 31 ms
21,880 KB
testcase_29 AC 99 ms
21,880 KB
testcase_30 AC 100 ms
22,204 KB
testcase_31 AC 19 ms
22,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;
int par[200010],sz[200010];
void init(int n){
	for(int i=0;i<n;i++) par[i] = i,sz[i] = 1;
}

int find(int x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]>sz[y]) swap(x,y);
	par[x] = y; sz[y] += sz[x];
}

bool same(int x, int y){
	return find(x)==find(y);
}

int query(int a,int b){
    cout << a + 1 << " " << b + 1 << endl;
    string t; cin >> t;
    if(t[0]=='B') return 1;
    else return 0;
}

bool used[1010][1010];
int mp[1010][1010];
void dfs(int x,int y,int n){
    if(used[x][y]) return;
    used[x][y] = true;
    int z = query(x,y);
    mp[x][y] = z;
    if(!mp[x][y]) return;
    if(x + 1<n) dfs(x + 1,y,n);
    if(x - 1>=0) dfs(x - 1,y,n);
    if(y + 1<n) dfs(x,y + 1,n);
    if(y - 1>=0) dfs(x,y - 1,n);
}

int main(){
    int i,j,n,m; cin >> n >> m;
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) used[i][j] = false;
    }
    dfs(0,0,n);
    if(used[n - 1][n - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}
0