結果

問題 No.1588 Connection
ユーザー korogisukorogisu
提出日時 2021-07-09 17:05:27
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,329 bytes
コンパイル時間 1,675 ms
コンパイル使用メモリ 177,620 KB
実行使用メモリ 24,324 KB
平均クエリ数 563.00
最終ジャッジ日時 2023-09-24 12:02:36
合計ジャッジ時間 4,830 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
23,424 KB
testcase_01 AC 23 ms
23,256 KB
testcase_02 AC 23 ms
23,928 KB
testcase_03 AC 23 ms
23,544 KB
testcase_04 AC 26 ms
23,460 KB
testcase_05 AC 26 ms
23,544 KB
testcase_06 AC 27 ms
23,112 KB
testcase_07 AC 23 ms
23,424 KB
testcase_08 AC 26 ms
23,568 KB
testcase_09 AC 27 ms
23,292 KB
testcase_10 AC 27 ms
23,868 KB
testcase_11 AC 27 ms
23,304 KB
testcase_12 AC 56 ms
24,108 KB
testcase_13 AC 62 ms
24,120 KB
testcase_14 AC 23 ms
24,096 KB
testcase_15 AC 24 ms
23,424 KB
testcase_16 AC 25 ms
23,532 KB
testcase_17 AC 24 ms
23,268 KB
testcase_18 AC 24 ms
23,928 KB
testcase_19 AC 26 ms
23,532 KB
testcase_20 AC 27 ms
23,640 KB
testcase_21 AC 104 ms
23,712 KB
testcase_22 AC 102 ms
23,544 KB
testcase_23 AC 59 ms
23,640 KB
testcase_24 AC 43 ms
24,024 KB
testcase_25 AC 64 ms
23,880 KB
testcase_26 AC 65 ms
24,324 KB
testcase_27 AC 44 ms
24,204 KB
testcase_28 AC 38 ms
23,580 KB
testcase_29 AC 106 ms
23,628 KB
testcase_30 AC 106 ms
23,544 KB
testcase_31 AC 25 ms
23,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n); i >= 0; i--)
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = (a); i >= (int)(n); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using P = pair<int, int>;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int N, M;
vector<vector<bool>> seen, masu;
queue<P> Q;


int main() {
    cin >> N >> M;
    seen.assign(N+1,vector<bool>(N+1));
    masu.assign(N+1,vector<bool>(N+1));
    Q.push({1,1});
    seen[1][1] = true;
    masu[1][1] = true;
    
    while(Q.size()) {
        int px, py;
        tie(px, py) = Q.front(); Q.pop();
        REP(i,4) {
            int ex = px + dx[i], ey = py + dy[i];
            if(ex <= 0 || ey <= 0 || ex > N || ey > N) continue;
            if(seen[ex][ey]) continue;

            cout << ex << " " << ey << endl;
            string nxt; cin >> nxt;

            if(nxt == "Black") {
                masu[ex][ey] = true;
                Q.push({ex,ey});
            }
            seen[ex][ey] = true;
        }
    }

    cout << (masu[N][N] ? "Yes" : "No") << endl;
    return 0;
}
0