結果
問題 | No.513 宝探し2 |
ユーザー | tac |
提出日時 | 2019-07-31 21:18:19 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 107 ms / 2,000 ms |
コード長 | 1,867 bytes |
コンパイル時間 | 1,736 ms |
コンパイル使用メモリ | 176,496 KB |
実行使用メモリ | 31,864 KB |
平均クエリ数 | 2.67 |
最終ジャッジ日時 | 2023-09-24 02:18:12 |
合計ジャッジ時間 | 3,398 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
23,844 KB |
testcase_01 | AC | 73 ms
25,272 KB |
testcase_02 | AC | 86 ms
28,396 KB |
testcase_03 | AC | 41 ms
24,060 KB |
testcase_04 | AC | 31 ms
23,832 KB |
testcase_05 | AC | 88 ms
28,416 KB |
testcase_06 | AC | 90 ms
29,116 KB |
testcase_07 | AC | 107 ms
31,864 KB |
testcase_08 | AC | 24 ms
23,568 KB |
testcase_09 | AC | 75 ms
25,436 KB |
testcase_10 | AC | 23 ms
23,400 KB |
testcase_11 | AC | 55 ms
25,912 KB |
ソースコード
#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 calc(int x, int y) { return abs(x - 100000) + abs(y - 50000); } 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; // m = calc(x, y); if (m == 0) break; rep(i, 100001) { 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; } } }