結果
| 問題 |
No.2962 Sum Bomb Bomber
|
| コンテスト | |
| ユーザー |
kwm_t
|
| 提出日時 | 2024-11-16 16:07:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 1,960 bytes |
| コンパイル時間 | 3,119 ms |
| コンパイル使用メモリ | 248,232 KB |
| 実行使用メモリ | 25,592 KB |
| 平均クエリ数 | 213.68 |
| 最終ジャッジ日時 | 2024-11-16 16:08:42 |
| 合計ジャッジ時間 | 12,762 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 64 |
ソースコード
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
//const int INF = 1e9;
//const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r) - 1;i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define P pair<int,int>
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
template<typename T, typename U>
std::pair<T, U> ternarysearch(T l, T r, const std::function<U(T)> &f) {
// 下に凸
while (2 < abs(r - l)) {
T ml = (l * 2 + r) / 3;
T mr = (l + r * 2) / 3;
if (f(ml) < f(mr)) r = mr;
else l = ml;
}
T ret = l;
U value = f(l);
for (T i = l; i <= r; ++i) {
auto tmp = f(i);
if (tmp < value) {
ret = i;
value = tmp;
}
}
return { ret,value };
}
long long local(int x, int y) {
int tx = 23, ty = 12;
return abs(tx - x) + abs(ty - y);
}
auto query(int x, int y) {
std::cout << 1 << " " << x << " " << y;
std::cout << std::endl;
fflush(stdout);
//return local(x, y);
long long get; std::cin >> get;
return get;
}
auto answer(int x, int y) {
std::cout << 2 << " " << x << " " << y;
std::cout << std::endl;
fflush(stdout);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; cin >> n;
auto f = [&](int x)->long long {
return query(x, 0);
};
auto[x, xv] = ternarysearch<int, long long>(-1e9, 1e9, f);
auto g = [&](int y)->long long {
return query(0, y);
};
auto[y, yv] = ternarysearch<int, long long>(-1e9, 1e9, g);
answer(x, y);
return 0;
}
kwm_t