結果
| 問題 | No.513 宝探し2 |
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2018-04-03 01:43:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 28 ms / 2,000 ms |
| コード長 | 1,613 bytes |
| 記録 | |
| コンパイル時間 | 886 ms |
| コンパイル使用メモリ | 84,076 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 55.33 |
| 最終ジャッジ日時 | 2024-07-17 01:41:50 |
| 合計ジャッジ時間 | 2,260 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
int main() {
int x1,x2,y1,y2;
x1 = y1 = -1;
x2 = y2 = 100001;
while ( true ) {
int a,b;
cout << x1 << " " << 0 << endl;
cout << flush;
cin >> a;
if ( a == 0 ) { return 0; }
cout << x2 << " " << 0 << endl;
cout << flush;
cin >> b;
if ( a == 0 ) { return 0; }
if ( abs(x1-x2) == 1 ) {
x1 = x2 = ( a < b ? x1 : x2 );
break;
}
if ( a < b ) {
x2 = (x1+x2)/2;
}
else if ( a > b ) {
x1 = (x1+x2)/2;
}
else {
x1 = x2 = (x1+x2)/2;
break;
}
}
while ( true ) {
int a,b;
cout << 0 << " " << y1 << endl;
cout << flush;
cin >> a;
if ( a == 0 ) { return 0; }
cout << 0 << " " << y2 << endl;
cout << flush;
cin >> b;
if ( a == 0 ) { return 0; }
if ( abs(y1-y2) == 1 ) {
y1 = y2 = ( a < b ? y1 : y2 );
break;
}
if ( a < b ) {
y2 = (y1+y2)/2;
}
else if ( a > b ) {
y1 = (y1+y2)/2;
}
else {
y1 = y2 = (y1+y2)/2;
break;
}
}
cout << x1 << " " << y1 << endl;
return 0;
}
tetsuzuki1115