結果
| 問題 |
No.1588 Connection
|
| コンテスト | |
| ユーザー |
pockyny
|
| 提出日時 | 2021-07-09 05:25:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| コード長 | 734 bytes |
| コンパイル時間 | 702 ms |
| コンパイル使用メモリ | 68,076 KB |
| 最終ジャッジ日時 | 2025-01-22 20:00:13 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 31 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
bool used[1010][1010];
int mp[1010][1010];
int query(int a,int b){
cout << a + 1 << " " << b + 1 << endl;
string t; cin >> t;
if(t[0]=='B') return 1;
return 0;
}
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;
}
pockyny