結果
| 問題 |
No.513 宝探し2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-05 23:53:53 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 891 bytes |
| コンパイル時間 | 1,038 ms |
| コンパイル使用メモリ | 68,908 KB |
| 実行使用メモリ | 25,604 KB |
| 平均クエリ数 | 64.50 |
| 最終ジャッジ日時 | 2024-07-16 13:29:45 |
| 合計ジャッジ時間 | 2,679 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 6 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;
const int n_bit = 20;
int query(bool isX, int val) {
if (isX) {
cout << val << " 0"<< endl;
} else {
cout << "0 " << val << endl;
}
int ret;
cin >> ret;
// printf("query val %3d, ret %3d\n", val, ret);
return ret;
}
int calc(bool isX) {
int width = (1 << n_bit) - 1;
int point = 0;
while (width > 0) {
// printf("-- point %3d width %3d\n", point, width);
int r = point + width;
int l = point - width;
int r_val = query(isX, r);
int l_val = query(isX, l);
if (r_val == l_val) {
return point;
} else if (r_val < l_val) {
point += width / 2;
} else {
point -= width / 2;
}
width /= 2;
}
return point;
}
int main() {
int x = calc(true);
int y = calc(false);
cout << x << " " << y << endl;
return 0;
}