結果

問題 No.1588 Connection
ユーザー NachiaNachia
提出日時 2021-07-08 23:57:11
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 684 ms
使用メモリ 22,864 KB
平均クエリ数 563.72
最終ジャッジ日時 2023-02-15 01:25:55
合計ジャッジ時間 3,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 20 ms
22,680 KB
testcase_01 AC 19 ms
21,940 KB
testcase_02 AC 20 ms
22,372 KB
testcase_03 AC 20 ms
21,980 KB
testcase_04 AC 20 ms
22,432 KB
testcase_05 AC 19 ms
21,940 KB
testcase_06 AC 20 ms
21,880 KB
testcase_07 AC 19 ms
22,692 KB
testcase_08 AC 22 ms
22,864 KB
testcase_09 AC 23 ms
22,564 KB
testcase_10 AC 23 ms
21,756 KB
testcase_11 AC 22 ms
22,576 KB
testcase_12 AC 50 ms
21,940 KB
testcase_13 AC 57 ms
22,576 KB
testcase_14 AC 19 ms
21,744 KB
testcase_15 AC 20 ms
21,880 KB
testcase_16 AC 19 ms
22,204 KB
testcase_17 AC 22 ms
22,276 KB
testcase_18 AC 20 ms
21,916 KB
testcase_19 AC 21 ms
22,716 KB
testcase_20 AC 22 ms
21,904 KB
testcase_21 AC 97 ms
22,564 KB
testcase_22 AC 97 ms
22,844 KB
testcase_23 AC 51 ms
22,108 KB
testcase_24 AC 36 ms
21,896 KB
testcase_25 AC 60 ms
22,432 KB
testcase_26 AC 58 ms
21,744 KB
testcase_27 AC 36 ms
21,892 KB
testcase_28 AC 31 ms
22,576 KB
testcase_29 AC 102 ms
22,576 KB
testcase_30 AC 101 ms
21,940 KB
testcase_31 AC 20 ms
21,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};

int N,M;
vector<vector<int>> visited;

int main(){
  cin >> N >> M;
  visited.assign(N+2,vector<int>(N+2,0));
  rep(i,N+2) visited[i][0] = visited[i][N+1] = 1;
  rep(i,N+2) visited[0][i] = visited[N+1][i] = 1;
  vector<int> I;
  I.push_back(0);
  visited[1][1] = 0;
  rep(i,I.size()){
    int p = I[i];
    int x = p%N;
    int y = p/N;
    rep(d,4){
      int nx = x+dx[d];
      int ny = y+dy[d];
      if(visited[ny+1][nx+1]) continue;
      visited[ny+1][nx+1] = 1;
      cout << (nx+1) << " " << (ny+1) << "\n" << flush;
      string res; cin >> res;
      if(res == "-1") exit(1);
      if(res == "White") continue;
      int ni = ny*N+nx;
      I.push_back(ni);
    }
  }
  if(visited[N][N] == 1) cout << "Yes\n"; else cout << "No\n";
  cout << flush;
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0