結果

問題 No.2978 Lexicographically Smallest and Largest Subarray
ユーザー titia
提出日時 2024-12-02 01:33:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 27,736 KB
平均クエリ数 1499.00
最終ジャッジ日時 2024-12-02 01:33:33
合計ジャッジ時間 17,177 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int,input().split())

WIN=[]
LOSE=[]

for i in range(1,N,2):
    print("?",i,N,i+1,N,flush=True)
    ans=int(input())

    if ans==0:
        WIN.append(i)
        LOSE.append(i+1)
    else:
        WIN.append(i+1)
        LOSE.append(i)

while len(WIN)>1:
    x=WIN.pop()
    y=WIN.pop()

    print("?",x,N,y,N,flush=True)
    ans=int(input())
    if ans==0:
        WIN.append(x)
    else:
        WIN.append(y)

while len(LOSE)>1:
    x=LOSE.pop()
    y=LOSE.pop()

    print("?",x,N,y,N,flush=True)
    ans=int(input())
    if ans==1:
        LOSE.append(x)
    else:
        LOSE.append(y)

      
print("!",LOSE[0],LOSE[0],WIN[0],N,flush=True)
0