結果

問題 No.1588 Connection
ユーザー pockynypockyny
提出日時 2021-07-08 23:11:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 1,093 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 69,372 KB
実行使用メモリ 25,332 KB
平均クエリ数 564.00
最終ジャッジ日時 2023-09-24 11:33:16
合計ジャッジ時間 3,833 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,168 KB
testcase_01 AC 26 ms
24,408 KB
testcase_02 AC 26 ms
23,772 KB
testcase_03 AC 26 ms
23,940 KB
testcase_04 AC 26 ms
24,036 KB
testcase_05 AC 26 ms
23,424 KB
testcase_06 AC 27 ms
24,288 KB
testcase_07 AC 25 ms
23,364 KB
testcase_08 AC 29 ms
23,352 KB
testcase_09 AC 29 ms
23,592 KB
testcase_10 AC 29 ms
23,604 KB
testcase_11 AC 29 ms
24,324 KB
testcase_12 AC 59 ms
23,964 KB
testcase_13 AC 66 ms
23,352 KB
testcase_14 AC 27 ms
23,820 KB
testcase_15 AC 27 ms
23,340 KB
testcase_16 AC 26 ms
23,964 KB
testcase_17 AC 25 ms
23,664 KB
testcase_18 AC 25 ms
23,532 KB
testcase_19 AC 27 ms
24,060 KB
testcase_20 AC 27 ms
23,676 KB
testcase_21 AC 109 ms
25,332 KB
testcase_22 AC 108 ms
25,264 KB
testcase_23 AC 59 ms
24,024 KB
testcase_24 AC 44 ms
24,036 KB
testcase_25 AC 70 ms
24,636 KB
testcase_26 AC 67 ms
24,004 KB
testcase_27 AC 45 ms
24,288 KB
testcase_28 AC 39 ms
23,844 KB
testcase_29 AC 112 ms
24,024 KB
testcase_30 AC 111 ms
23,376 KB
testcase_31 AC 25 ms
23,484 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