結果

問題 No.1588 Connection
ユーザー fumofumofunifumofumofuni
提出日時 2021-07-12 13:05:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 2,000 ms
コード長 1,547 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 207,476 KB
実行使用メモリ 24,348 KB
平均クエリ数 551.78
最終ジャッジ日時 2023-09-24 12:05:22
合計ジャッジ時間 5,595 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,664 KB
testcase_01 AC 27 ms
23,328 KB
testcase_02 AC 25 ms
23,484 KB
testcase_03 AC 26 ms
23,304 KB
testcase_04 AC 26 ms
23,568 KB
testcase_05 AC 26 ms
24,348 KB
testcase_06 AC 28 ms
24,264 KB
testcase_07 AC 25 ms
23,472 KB
testcase_08 AC 29 ms
23,976 KB
testcase_09 AC 29 ms
23,604 KB
testcase_10 AC 29 ms
23,316 KB
testcase_11 AC 30 ms
23,724 KB
testcase_12 AC 60 ms
24,288 KB
testcase_13 AC 64 ms
23,340 KB
testcase_14 AC 26 ms
23,460 KB
testcase_15 AC 27 ms
23,904 KB
testcase_16 AC 26 ms
24,336 KB
testcase_17 AC 26 ms
23,964 KB
testcase_18 AC 27 ms
23,964 KB
testcase_19 AC 27 ms
23,904 KB
testcase_20 AC 29 ms
24,312 KB
testcase_21 AC 108 ms
24,012 KB
testcase_22 AC 108 ms
24,300 KB
testcase_23 AC 59 ms
23,472 KB
testcase_24 AC 44 ms
23,640 KB
testcase_25 AC 71 ms
23,304 KB
testcase_26 AC 69 ms
23,676 KB
testcase_27 AC 44 ms
23,976 KB
testcase_28 AC 39 ms
23,304 KB
testcase_29 AC 105 ms
24,348 KB
testcase_30 AC 109 ms
24,012 KB
testcase_31 AC 27 ms
23,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=(n)-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,1,0,-1,1,-1,1,-1};
template <typename T> inline bool chmax(T &a, T b) {
  return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
  return ((a > b) ? (a = b, true) : (false));
}
ll n,m;
int main(){
  cin >> n >> m;
  queue<pl> que;
  que.push({0,0});
  vvl seen(n,vl(n,-1));seen[0][0]=1;
  while(!que.empty()){
    auto v=que.front();que.pop();
    if(v.fi==n-1&&v.se==n-1){
      cout << "Yes" <<endl;return 0;
    }
    rep(i,4){
      ll nx=v.fi+dx[i];
      ll ny=v.se+dy[i];
      if(nx<0||nx>=n||ny<0||ny>=n)continue;
      if(seen[nx][ny]!=-1)continue;
      cout << nx+1 <<" " << ny+1 <<endl;
      string s;cin >> s;
      if(s=="Black"){
        seen[nx][ny]=1;
        que.push({nx,ny});
      }
      else seen[nx][ny]=0;
    }
  }
  cout << "No" <<endl;
}
0