結果
| 問題 |
No.594 壊れた宝物発見機
|
| コンテスト | |
| ユーザー |
femto
|
| 提出日時 | 2017-11-10 22:33:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 116 ms / 2,000 ms |
| コード長 | 813 bytes |
| コンパイル時間 | 1,584 ms |
| コンパイル使用メモリ | 167,564 KB |
| 実行使用メモリ | 25,488 KB |
| 平均クエリ数 | 50.60 |
| 最終ジャッジ日時 | 2024-07-16 14:24:47 |
| 合計ジャッジ時間 | 5,287 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// 質問クエリ
int ask(int x, int y, int z){
int d;
cout << "?" << " " << x << " " << y << " " << z << endl;
cin >> d;
return d;
}
// 回答クエリ
void answer(int x, int y, int z){
cout << "!" << " " << x << " " << y << " " << z << endl;
}
ll X[3];
// [from, to)
ll findMin(ll from, ll to, int idx){
for(; to - from > 1;){
ll mid = (from + to) / 2;
X[idx] = mid - 1;
ll d1 = ask(X[0], X[1], X[2]);
X[idx] = mid;
ll d2 = ask(X[0], X[1], X[2]);
(d1 > d2 ? from : to) = mid;
}
return from;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
#ifdef LOCAL
std::ifstream in("in");
std::cin.rdbuf(in.rdbuf());
#endif
for(int i = 0; i < 3; i++){
X[i] = findMin(-150, 151, i);
}
answer(X[0], X[1], X[2]);
}
femto