結果

問題 No.594 壊れた宝物発見機
ユーザー 👑 KazunKazun
提出日時 2021-03-02 18:54:24
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 1,370 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 87,724 KB
平均クエリ数 78.50
最終ジャッジ日時 2023-09-24 09:51:48
合計ジャッジ時間 6,651 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 207 ms
87,208 KB
testcase_01 AC 202 ms
87,280 KB
testcase_02 AC 204 ms
87,380 KB
testcase_03 AC 203 ms
87,440 KB
testcase_04 AC 199 ms
87,716 KB
testcase_05 AC 204 ms
87,468 KB
testcase_06 AC 200 ms
87,268 KB
testcase_07 AC 202 ms
87,348 KB
testcase_08 AC 201 ms
87,160 KB
testcase_09 AC 201 ms
87,456 KB
testcase_10 AC 201 ms
87,052 KB
testcase_11 AC 203 ms
87,288 KB
testcase_12 AC 204 ms
87,356 KB
testcase_13 AC 202 ms
87,044 KB
testcase_14 AC 202 ms
87,724 KB
testcase_15 AC 202 ms
87,296 KB
testcase_16 AC 201 ms
87,108 KB
testcase_17 AC 200 ms
87,224 KB
testcase_18 AC 199 ms
87,292 KB
testcase_19 AC 199 ms
87,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Ternary_Search_Minimize(L,R,f,Integer=True,arg=False,ep=1/(1<<20),Times=50):
    """3部探索による最小値を求める.

    f:[L,R]内で下に凸または単調減少
    """
    if Integer:
        while (R-L)>3:
            a=(2*L+R)//3
            b=(L+2*R)//3
            p=f(a);q=f(b)
            if p<=q:
                R=b
            else:
                L=a

        a=(2*L+R)//3
        b=(L+2*R)//3
    else:
        while (R-L)>=ep and Times:
            Times-=1
            a=(2*L+R)/3
            b=(L+2*R)/3

            p=f(a);q=f(b)
            if p<=q:
                R=b
            else:
                L=a

        a=(2*L+R)/3
        b=(L+2*R)/3

    if arg:
        y=float("inf")
        argx=-1
        for x in [L,a,b,R]:
            p=f(x)
            if y>p:
                y=p
                argx=x
        return y,argx
    else:
        return min(f(L),f(a),f(b),f(R))
#================================================
def quest(x,y,z):
    print("?",x,y,z)
    return int(input())

def answer(x,y,z):
    print("!",x,y,z)
    exit()
#================================================
f=lambda x:quest(x,0,0)
g=lambda y:quest(0,y,0)
h=lambda z:quest(0,0,z)

_,X=Ternary_Search_Minimize(-100,100,f,True,True)
_,Y=Ternary_Search_Minimize(-100,100,g,True,True)
_,Z=Ternary_Search_Minimize(-100,100,h,True,True)
answer(X,Y,Z)
0