結果

問題 No.1588 Connection
ユーザー KudeKude
提出日時 2021-07-08 23:17:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
QLE  
(最初)
実行時間 -
コード長 1,702 bytes
コンパイル時間 4,252 ms
コンパイル使用メモリ 260,008 KB
実行使用メモリ 24,492 KB
平均クエリ数 12.78
最終ジャッジ日時 2023-09-24 11:35:39
合計ジャッジ時間 8,929 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
23,964 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 25 ms
23,352 KB
testcase_10 AC 23 ms
23,952 KB
testcase_11 AC 25 ms
23,976 KB
testcase_12 AC 26 ms
23,592 KB
testcase_13 AC 27 ms
23,940 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i,n)for (int i = 0; i < int(n); ++i)
#define rrep(i,n)for (int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

int n, m;
int query(int i, int j) {
    cout << i + 1 << ' ' << j + 1 << endl;
    string ret;
    cin >> ret;
    if (ret == "-1") exit(0);
    return ret == "Black";
}

int state[500][500];
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    rep(i, 500) rep(j, 500) state[i][j] = -1;
    state[0][0] = 1;
    cin >> n >> m;
    rep(_, 2999) {
        int d = 1001001001;
        int qi = -1, qj = -1;
        rep(i, n) rep(j, n) if (state[i][j] == -1) {
            int t = n - 1 - i + n - 1 - j;
            if (t >= d) continue;
            bool ok = false;
            rep(k, 4) {
                int ni = i + dx[k], nj = j + dy[k];
                if (!(0 <= ni && ni < n && 0 <= nj && nj < n)) continue;
                if (state[ni][nj] == 1) {
                    ok = true;
                    break;
                }
            }
            if (!ok) continue;
            d = t;
            qi = i, qj = j;
        }
        if (d == 0) {
            cout << "Yes\n";
            return 0;
        }
        state[qi][qj] = query(qi, qj);
    }
    cout << "No\n";
}
0