結果

問題 No.1588 Connection
ユーザー hayatenhayaten
提出日時 2021-07-09 12:49:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,639 bytes
コンパイル時間 5,177 ms
コンパイル使用メモリ 281,672 KB
実行使用メモリ 24,372 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-09-24 12:00:17
合計ジャッジ時間 8,536 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,060 KB
testcase_01 AC 23 ms
24,072 KB
testcase_02 AC 22 ms
23,556 KB
testcase_03 AC 22 ms
23,256 KB
testcase_04 AC 22 ms
23,880 KB
testcase_05 AC 23 ms
23,556 KB
testcase_06 AC 24 ms
23,292 KB
testcase_07 AC 22 ms
23,856 KB
testcase_08 AC 23 ms
23,688 KB
testcase_09 AC 24 ms
24,240 KB
testcase_10 AC 25 ms
23,304 KB
testcase_11 AC 26 ms
23,268 KB
testcase_12 AC 54 ms
24,252 KB
testcase_13 AC 60 ms
23,928 KB
testcase_14 AC 24 ms
23,256 KB
testcase_15 AC 26 ms
23,868 KB
testcase_16 AC 24 ms
23,868 KB
testcase_17 AC 24 ms
23,544 KB
testcase_18 AC 24 ms
24,372 KB
testcase_19 AC 24 ms
24,348 KB
testcase_20 AC 25 ms
23,928 KB
testcase_21 AC 101 ms
23,688 KB
testcase_22 AC 101 ms
23,412 KB
testcase_23 AC 55 ms
24,132 KB
testcase_24 AC 40 ms
23,928 KB
testcase_25 AC 63 ms
23,880 KB
testcase_26 AC 62 ms
23,928 KB
testcase_27 AC 43 ms
23,256 KB
testcase_28 AC 36 ms
23,880 KB
testcase_29 AC 107 ms
23,268 KB
testcase_30 AC 101 ms
23,700 KB
testcase_31 AC 24 ms
23,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma region Macros
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define popcount(bit) __builtin_popcount(bit)
#define pb push_back
#define eb emplace_back
using namespace std;
using namespace atcoder;
using P = pair<int, int>;
using PL = pair<long long, long long>;
typedef long long ll;
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 dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int fx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int fy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<bool>> dist(n, vector<bool>(n, false));
  vector<vector<bool>> black(n, vector<bool>(n, false));
  dist[0][0] = true;
  queue<P> que;
  que.push(P(0, 0));
  auto cond = [&](int a, int b){
    cout << a << " " << b << endl;
    cout.flush();
    string s;
    cin >> s;
    return s == "Black";
  };
  while (!que.empty()){
    P p = que.front();
    que.pop();
    rep(i, 4){
      int nx = p.first + dx[i], ny = p.second + dy[i];
      if(nx < 0 || ny < 0 || nx >= n || ny >= n)continue;
      if(dist[nx][ny])continue;
      if(cond(nx + 1, ny + 1)){
        black[nx][ny] = true;
        que.push(P(nx, ny));
      }
      dist[nx][ny] = true;
    }
  }
  if(black[n-1][n-1]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
0