結果

問題 No.513 宝探し2
ユーザー noynotenoynote
提出日時 2017-05-05 23:26:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 1,621 bytes
コンパイル時間 1,146 ms
コンパイル使用メモリ 145,296 KB
実行使用メモリ 24,300 KB
平均クエリ数 37.25
最終ジャッジ日時 2023-09-24 01:07:48
合計ジャッジ時間 2,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,132 KB
testcase_01 AC 28 ms
24,300 KB
testcase_02 AC 27 ms
23,664 KB
testcase_03 AC 28 ms
23,652 KB
testcase_04 AC 28 ms
24,264 KB
testcase_05 AC 25 ms
23,988 KB
testcase_06 AC 24 ms
23,604 KB
testcase_07 AC 25 ms
23,652 KB
testcase_08 AC 25 ms
23,604 KB
testcase_09 AC 25 ms
24,300 KB
testcase_10 AC 24 ms
24,036 KB
testcase_11 AC 25 ms
23,400 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:9: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         switch (p) {
         ^~~~~~

ソースコード

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 = 100000;

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,20){
        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 mini = MAX * 3;
        int p;
        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