結果

問題 No.513 宝探し2
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-04-03 01:43:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,613 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 24,348 KB
平均クエリ数 55.33
最終ジャッジ日時 2023-09-24 01:44:24
合計ジャッジ時間 1,970 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
23,856 KB
testcase_01 AC 27 ms
23,388 KB
testcase_02 AC 26 ms
23,220 KB
testcase_03 AC 27 ms
23,868 KB
testcase_04 AC 27 ms
23,244 KB
testcase_05 AC 26 ms
23,412 KB
testcase_06 AC 24 ms
24,348 KB
testcase_07 AC 24 ms
23,412 KB
testcase_08 AC 25 ms
24,228 KB
testcase_09 AC 27 ms
23,844 KB
testcase_10 AC 26 ms
23,244 KB
testcase_11 AC 26 ms
23,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0