結果

問題 No.1588 Connection
ユーザー bdbmilk37bdbmilk37
提出日時 2021-07-10 08:44:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 122 ms / 2,000 ms
コード長 1,234 bytes
コンパイル時間 2,079 ms
コンパイル使用メモリ 208,268 KB
実行使用メモリ 24,528 KB
平均クエリ数 636.16
最終ジャッジ日時 2023-09-24 12:04:34
合計ジャッジ時間 5,429 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
23,412 KB
testcase_01 AC 26 ms
23,664 KB
testcase_02 AC 25 ms
24,096 KB
testcase_03 AC 26 ms
23,400 KB
testcase_04 AC 26 ms
24,000 KB
testcase_05 AC 26 ms
23,676 KB
testcase_06 AC 27 ms
23,556 KB
testcase_07 AC 26 ms
24,384 KB
testcase_08 AC 30 ms
24,384 KB
testcase_09 AC 31 ms
23,556 KB
testcase_10 AC 30 ms
23,856 KB
testcase_11 AC 30 ms
23,544 KB
testcase_12 AC 61 ms
23,676 KB
testcase_13 AC 79 ms
23,556 KB
testcase_14 AC 26 ms
23,424 KB
testcase_15 AC 27 ms
23,400 KB
testcase_16 AC 26 ms
24,396 KB
testcase_17 AC 26 ms
24,240 KB
testcase_18 AC 27 ms
23,628 KB
testcase_19 AC 26 ms
23,448 KB
testcase_20 AC 28 ms
23,856 KB
testcase_21 AC 121 ms
23,664 KB
testcase_22 AC 122 ms
24,072 KB
testcase_23 AC 64 ms
23,700 KB
testcase_24 AC 47 ms
24,084 KB
testcase_25 AC 76 ms
23,664 KB
testcase_26 AC 71 ms
24,072 KB
testcase_27 AC 45 ms
24,528 KB
testcase_28 AC 42 ms
23,448 KB
testcase_29 AC 104 ms
23,400 KB
testcase_30 AC 105 ms
23,412 KB
testcase_31 AC 25 ms
23,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define quit(a) {cout << a << endl; return 0;}
using ll = long long;
using P = pair<int,int>;
// using mint = modint998244353;
// using mint = modint1000000007;
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1001001001;
const ll LINF = 1002003004005006007ll;


int main() {
  int n, m;
  cin >> n >> m;
  vector g(n,vector<bool>(n,false));
  g[0][0] = true;
  queue<P> q;
  q.push({0,0});
  int di[4] = {0,1,0,-1};
  int dj[4] = {1,0,-1,0};
  while (!q.empty()){
    auto [i,j] = q.front(); q.pop();
    if (i == n-1 && j == n-1) quit("Yes");
    rep(d,4){
      int ni = i + di[d];
      int nj = j + dj[d];
      if ((ni < 0) || (ni >= n) || (nj < 0) || (nj >= n)) continue;
      if (g[ni][nj]) continue;
      printf("%d %d\n",ni+1,nj+1);
      string s;
      cin >> s;
      if (s == "Black") q.push({ni,nj}), g[ni][nj] = true;
    }
  }
  cout << "No" << endl;
  return 0;
}
0