結果

問題 No.2978 Lexicographically Smallest and Largest Subarray
コンテスト
ユーザー flippergo
提出日時 2026-08-14 10:57:08
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 262 ms / 2,000 ms
+ 4µs
コード長 789 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 247 ms
コンパイル使用メモリ 96,240 KB
実行使用メモリ 84,260 KB
平均クエリ数 1499.00
最終ジャッジ日時 2026-08-14 10:57:25
合計ジャッジ時間 14,897 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 57
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,Q = map(int,input().split())
H = []
L = []
for i in range(1,N,2):
    print(f"? {i} {N} {i+1} {N}")
    x = int(input())
    if x==1:
        L.append(i)
        H.append(i+1)
    else:
        L.append(i+1)
        H.append(i)
while len(H)>1:
    i1 = H.pop()
    i2 = H.pop()
    print(f"? {i1} {N} {i2} {N}")
    x = int(input())
    if x==1:
        H.append(i2)
    else:
        H.append(i1)
while len(L)>1:
    i1 = L.pop()
    i2 = L.pop()
    print(f"? {i1} {N} {i2} {N}")
    x = int(input())
    if x==1:
        L.append(i1)
    else:
        L.append(i2)
if N%2==1:
    print(f"? {H[0]} {N} {N} {N}")
    x = int(input())
    if x==1:
        H[0] = N
    print(f"? {L[0]} {N} {N} {N}")
    x = int(input())
    if x==0:
        L[0] = N
print(f"! {L[0]} {L[0]} {H[0]} {N}")
0