結果

問題 No.1588 Connection
ユーザー SSRSSSRS
提出日時 2021-07-08 22:28:39
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 1,542 ms
使用メモリ 22,876 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-02-15 00:00:58
合計ジャッジ時間 4,771 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 22 ms
22,612 KB
testcase_01 AC 21 ms
21,940 KB
testcase_02 AC 23 ms
21,904 KB
testcase_03 AC 22 ms
21,892 KB
testcase_04 AC 22 ms
21,736 KB
testcase_05 AC 22 ms
21,940 KB
testcase_06 AC 22 ms
22,612 KB
testcase_07 AC 22 ms
22,468 KB
testcase_08 AC 23 ms
22,432 KB
testcase_09 AC 25 ms
21,892 KB
testcase_10 AC 26 ms
21,928 KB
testcase_11 AC 25 ms
22,876 KB
testcase_12 AC 55 ms
21,768 KB
testcase_13 AC 62 ms
21,892 KB
testcase_14 AC 22 ms
22,844 KB
testcase_15 AC 22 ms
21,880 KB
testcase_16 AC 23 ms
22,264 KB
testcase_17 AC 24 ms
22,476 KB
testcase_18 AC 22 ms
21,824 KB
testcase_19 AC 23 ms
21,892 KB
testcase_20 AC 25 ms
22,004 KB
testcase_21 AC 106 ms
21,756 KB
testcase_22 AC 107 ms
22,608 KB
testcase_23 AC 56 ms
22,432 KB
testcase_24 AC 40 ms
21,880 KB
testcase_25 AC 66 ms
22,588 KB
testcase_26 AC 65 ms
21,992 KB
testcase_27 AC 40 ms
21,880 KB
testcase_28 AC 34 ms
21,916 KB
testcase_29 AC 111 ms
22,608 KB
testcase_30 AC 112 ms
21,928 KB
testcase_31 AC 23 ms
21,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<int> dx = {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
void dfs(vector<vector<int>> &S, int x, int y){
  int N = S.size();
  for (int i = 0; i < 4; i++){
    int x2 = x + dx[i];
    int y2 = y + dy[i];
    if (0 <= x2 && x2 < N && 0 <= y2 && y2 < N){
      if (S[x2][y2] == -1){
        cout << x2 + 1 << ' ' << y2 + 1 << endl;
        string s;
        cin >> s;
        if (s == "White"){
          S[x2][y2] = 0;
        }
        if (s == "Black"){
          S[x2][y2] = 1;
          dfs(S, x2, y2);
        }
      }
    }
  }
}
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(N, vector<int>(N, -1));
  S[0][0] = 1;
  dfs(S, 0, 0);
  if (S[N - 1][N - 1] == 1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0