結果

問題 No.594 壊れた宝物発見機
ユーザー dnishdnish
提出日時 2018-06-23 10:40:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 1,529 ms
コンパイル使用メモリ 164,788 KB
実行使用メモリ 24,336 KB
平均クエリ数 70.20
最終ジャッジ日時 2023-09-23 16:06:41
合計ジャッジ時間 4,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
23,340 KB
testcase_01 AC 96 ms
23,364 KB
testcase_02 AC 98 ms
23,388 KB
testcase_03 AC 96 ms
24,336 KB
testcase_04 AC 101 ms
24,240 KB
testcase_05 AC 98 ms
23,376 KB
testcase_06 AC 97 ms
23,544 KB
testcase_07 AC 96 ms
24,324 KB
testcase_08 AC 96 ms
23,376 KB
testcase_09 AC 101 ms
23,580 KB
testcase_10 AC 100 ms
24,312 KB
testcase_11 AC 99 ms
23,976 KB
testcase_12 AC 101 ms
24,300 KB
testcase_13 AC 99 ms
23,976 KB
testcase_14 AC 98 ms
23,424 KB
testcase_15 AC 96 ms
23,652 KB
testcase_16 AC 101 ms
24,288 KB
testcase_17 AC 100 ms
23,604 KB
testcase_18 AC 105 ms
23,376 KB
testcase_19 AC 96 ms
23,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod= 1e10;

void answer(int *a){
    printf("! %d %d %d\n", a[0], a[1], a[2]);
    fflush(stdout);
}

int ask(int *a){
    printf("? %d %d %d\n", a[0], a[1], a[2]);
    fflush(stdout);
    int d;
    scanf("%d", &d);
    return d;
}

void calc(int *a, int p){
    int lb = -100, ub = 101;
    while(ub-lb>5){
        int lb2 = (2*lb+ub)/3;
        a[p] = lb2;
        int l = ask(a);
        int ub2 = (lb+2*ub)/3;
        a[p] = ub2;
        int r = ask(a);
        if(l<r) ub = ub2;
        else lb = lb2;
    }
    a[p] = lb;
    int x = ask(a);
    while(true){
        a[p]++;
        int y = ask(a);
        if(y<x){
            x = y;
            continue;
        }
        --a[p];
        return;
    }
}

int main(){
    int a[3] = {0, 0, 0};
    REP(i,0, 3) calc(a, i);
    answer(a);
    return 0;
}
0