結果

問題 No.1588 Connection
ユーザー carrot46carrot46
提出日時 2021-07-08 22:46:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,825 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 207,292 KB
実行使用メモリ 24,336 KB
平均クエリ数 488.50
最終ジャッジ日時 2023-09-24 10:48:53
合計ジャッジ時間 5,293 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
24,288 KB
testcase_01 AC 25 ms
24,012 KB
testcase_02 AC 27 ms
23,820 KB
testcase_03 AC 26 ms
23,544 KB
testcase_04 AC 25 ms
24,288 KB
testcase_05 AC 26 ms
23,592 KB
testcase_06 AC 27 ms
24,336 KB
testcase_07 AC 26 ms
23,988 KB
testcase_08 AC 28 ms
23,652 KB
testcase_09 AC 28 ms
23,532 KB
testcase_10 AC 29 ms
24,228 KB
testcase_11 AC 29 ms
24,300 KB
testcase_12 AC 57 ms
24,312 KB
testcase_13 AC 62 ms
23,676 KB
testcase_14 AC 27 ms
23,388 KB
testcase_15 AC 26 ms
24,300 KB
testcase_16 AC 26 ms
24,000 KB
testcase_17 AC 26 ms
24,048 KB
testcase_18 AC 26 ms
24,336 KB
testcase_19 AC 27 ms
24,336 KB
testcase_20 AC 29 ms
23,616 KB
testcase_21 AC 100 ms
23,652 KB
testcase_22 AC 100 ms
23,424 KB
testcase_23 AC 55 ms
23,664 KB
testcase_24 AC 42 ms
23,364 KB
testcase_25 AC 70 ms
23,664 KB
testcase_26 AC 69 ms
23,832 KB
testcase_27 AC 44 ms
23,796 KB
testcase_28 AC 39 ms
23,604 KB
testcase_29 AC 97 ms
23,496 KB
testcase_30 AC 77 ms
23,340 KB
testcase_31 AC 26 ms
23,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using namespace atcoder;
//#pragma GCC optimize("Ofast")
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

ll N,M,H,W,Q,K,A,B;
string S;
using P = pair<ll, ll>;
using tp = tuple<ll, ll, ll>;
const ll INF = (1LL<<60);

template<class T> bool chmin(T &a, const T b){
    if(a > b) {a = b; return true;}
    else return false;
}
template<class T> bool chmax(T &a, const T b){
    if(a < b) {a = b; return true;}
    else return false;
}
template<class T> void my_printv(std::vector<T> v,bool endline = true){
    if(!v.empty()){
        for(std::size_t i{}; i<v.size()-1; ++i) std::cout<<v[i]<<" ";
        std::cout<<v.back();
    }
    if(endline) std::cout<<std::endl;
}

void yn(bool yes){
    cout<<(yes ? "Yes" : "No")<<endl;
    exit(0);
}

bool ask_white(int i, int j){
    cout<<i + 1<<' '<<j + 1<<endl;
    string s;
    cin>>s;
    if(s == "-1") exit(1);
    return s == "White";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin>>N>>M;
    const vector<int> di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1};
    mat G(N, vec(N, -1));
    G[0][0] = 0;
    auto dfs = [&](auto &&self, int i, int j) -> void{
        if(i == N - 1 && j == N - 1) yn(true);
        rep(k, 4){
            int ni = i + di[k], nj = j + dj[k];
            if(ni >= 0 && ni < N && nj >= 0 && nj < N){
                if(G[ni][nj] == -1){
                    G[ni][nj] = ask_white(ni, nj);
                    if(G[ni][nj] == 0) self(self, ni, nj);
                }
            }
        }
    };
    dfs(dfs, 0, 0);
    yn(false);
}
0