結果

問題 No.594 壊れた宝物発見機
ユーザー TsReaperTsReaper
提出日時 2018-03-26 17:45:27
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 28,296 KB
実行使用メモリ 24,456 KB
平均クエリ数 80.80
最終ジャッジ日時 2023-09-23 15:59:30
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
24,396 KB
testcase_01 AC 93 ms
23,868 KB
testcase_02 AC 89 ms
23,568 KB
testcase_03 AC 89 ms
23,400 KB
testcase_04 AC 93 ms
23,832 KB
testcase_05 AC 92 ms
23,388 KB
testcase_06 AC 102 ms
23,640 KB
testcase_07 AC 95 ms
23,544 KB
testcase_08 AC 92 ms
23,556 KB
testcase_09 AC 91 ms
23,448 KB
testcase_10 AC 93 ms
23,580 KB
testcase_11 AC 95 ms
23,652 KB
testcase_12 AC 92 ms
24,060 KB
testcase_13 AC 95 ms
23,412 KB
testcase_14 AC 94 ms
23,568 KB
testcase_15 AC 91 ms
24,048 KB
testcase_16 AC 99 ms
23,424 KB
testcase_17 AC 94 ms
24,456 KB
testcase_18 AC 94 ms
23,436 KB
testcase_19 AC 98 ms
23,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#define UKN 200

int check(int x,int y,int z,int v)
{
    int ret;

    if(x == UKN) printf("? %d %d %d\n",v,y,z);
    else if(y == UKN) printf("? %d %d %d\n",x,v,z);
    else printf("? %d %d %d\n",x,y,v);
    fflush(stdout);

    scanf("%d",&ret);
    return ret;
}

int work(int x,int y,int z)
{
    int head,tail,mid1,mid2,d1,d2;
    int best,ret;

    head = -150; tail = 150;
    while(tail-head > 5)
    {
        mid1 = head + (tail-head)/3;
        mid2 = head + (tail-head)*2/3;
        d1 = check(x,y,z,mid1);
        d2 = check(x,y,z,mid2);
        if(d1 > d2) head = mid1;
        else tail = mid2;
    }

    best = check(x,y,z,head); ret = head;
    for(head++;head<=tail;head++)
    {
        d1 = check(x,y,z,head);
        if(d1 < best) best = d1, ret = head;
    }
    return ret;
}

int main()
{
    int x,y,z;
    x = work(UKN,0,0);
    y = work(x,UKN,0);
    z = work(x,y,UKN);
    printf("! %d %d %d\n",x,y,z);
    fflush(stdout);
    return 0;
}
0