結果

問題 No.513 宝探し2
ユーザー tactac
提出日時 2019-07-31 21:15:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,768 bytes
コンパイル時間 1,980 ms
コンパイル使用メモリ 175,560 KB
実行使用メモリ 40,880 KB
平均クエリ数 1.50
最終ジャッジ日時 2023-09-23 17:57:28
合計ジャッジ時間 5,936 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,484 KB
testcase_01 AC 75 ms
25,572 KB
testcase_02 AC 89 ms
28,004 KB
testcase_03 AC 44 ms
24,036 KB
testcase_04 AC 33 ms
23,916 KB
testcase_05 AC 90 ms
28,320 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = (a >= b ? a : b)
#define chmin(a, b) a = (a <= b ? a : b)
#define out(a) cout << a << endl
#define outa(a, n) rep(_, n) cout << a[_] << " "; cout << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    map<pii, int> mp;
    int x = 0, y = 0;
    int m;
    while (1) {
        cout << x << " " << y << endl;
        cin >> m;
        if (m == 0) break;
        rep(i, 100000) {
            int b = m - abs(x - i);
            if (b < 0 || b > 100000) continue;
            vector<int> v;
            int j = y - b;
            if (j >= 0 && j <= 100000) v.eb(j);
            int j2 = y + b;
            if (j2 >= 0 && j2 <= 100000 && j != j2) v.eb(j2);
            rep(j, SZ(v)) {
                if (x == 0 && y == 0) {
                    mp[{i, v[j]}]++;
                } else {
                    if (mp[{i, v[j]}] == 1) mp[{i, v[j]}]++;
                }
            }
        }
        if (!(x == 0 && y == 0)) {
            for (auto e : mp) {
                if (e.S == 1) mp[{e.F.F, e.F.S}] = 0;
                else if (e.S == 2) mp[{e.F.F, e.F.S}] = 1;
                // out(e.F.F << " " << e.F.S << " " << e.S);
            }
        }
        for (auto e : mp) {
            if (e.S == 0) continue;
            // out(e.F.F << " " << e.F.S << " " << e.S);
            x = e.F.F;
            y = e.F.S;
            break;
        }
    }
}

0