結果
| 問題 | No.513 宝探し2 |
| コンテスト | |
| ユーザー |
tac
|
| 提出日時 | 2019-07-31 21:18:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 108 ms / 2,000 ms |
| コード長 | 1,867 bytes |
| 記録 | |
| コンパイル時間 | 1,632 ms |
| コンパイル使用メモリ | 179,808 KB |
| 実行使用メモリ | 32,472 KB |
| 平均クエリ数 | 2.67 |
| 最終ジャッジ日時 | 2024-07-17 02:19:40 |
| 合計ジャッジ時間 | 3,380 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#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;
}
}
}
tac