結果

問題 No.514 宝探し3
ユーザー noynotenoynote
提出日時 2017-05-05 23:58:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,186 bytes
コンパイル時間 2,136 ms
コンパイル使用メモリ 146,208 KB
実行使用メモリ 24,444 KB
平均クエリ数 46.42
最終ジャッジ日時 2023-09-23 13:51:41
合計ジャッジ時間 4,086 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 25 ms
24,264 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const int MAX = 1000000000;

const int dy[16] = { 1,-1, 1,-1, 0,-2, 0, 2};
const int dx[16] = { 1, 1,-1,-1, 2, 0,-2, 0};

int main(){
    int x, y;
    int x_right = MAX, x_left = 0;
    int y_right = MAX, y_left = 0;
    rep(i,30){
        x = (x_right + x_left) / 2;
        y = (y_right + y_left) / 2;
        cout << x << ' ' << y << endl;
        int d;
        cin >> d;
        if(d == 0){
            cout << x << ' ' << y << endl;
            return 0;
        }

        int p = -1;
        if(d > 2){
            int tmp;
            cout << x + dx[0] * d / 2 << ' ' << y + dy[0] * d / 2 << endl;
            cin >> tmp;
            if(d - tmp < d / 2) p = 0;
            else if(tmp == d * 2) p = 2;
            else{
                cout << x + dx[0] * d / 2 << ' ' << y + dy[0] * d / 2 << endl;
                cin >> tmp;
                if(d - tmp < d / 2) p = 1;
                else if(tmp == d * 2) p = 3;
            }
            assert(p != -1);
        }else{
            int mini = MAX + 1;
            rep(j,4){
                cout << x + dx[j] * max(1,d / 2) << ' ' << y + dy[j] * max(1,d / 2) << endl;
                int tmp;
                cin >> tmp;
                if(tmp == 0){
                    cout << x + dx[j] * d / 2 << ' ' << y + dy[j] * d / 2<< endl;
                    return 0;
                }
                if(mini > tmp){
                    mini = tmp;
                    p = j;
                }
            }
        }

        switch (p) {
            case 0:
                x_left = x;
                y_left = y;
                break;
            case 1:
                x_left = x;
                y_right = y;
                break;
            case 2:
                x_right = x;
                y_left = y;
                break;
            case 3:
                x_right = x;
                y_right = y;
                break;
        }
    }
    cout << x << ' ' << y << endl;
}
0