結果
問題 |
No.2978 Lexicographically Smallest and Largest Subarray
|
ユーザー |
|
提出日時 | 2024-12-02 12:32:19 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 82,304 KB |
平均クエリ数 | 2.00 |
最終ジャッジ日時 | 2024-12-02 12:32:52 |
合計ジャッジ時間 | 11,710 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 57 |
ソースコード
import collections n,q = map(int,input().split()) def query(a,b,c,d): print('?',a,b,c,d,flush=True) x = int(input()) return x a = collections.deque(range(n)) b = collections.deque() c = collections.deque() for i in range(n//2): x = a.popleft() y = a.popleft() z = query(x,x,y,y) if z == 1: c.append(x) b.append(y) else: c.append(y) b.append(x) a = c + a while len(a) > 1: c = collections.deque() while a: x = a.popleft() y = a.popleft() z = query(x,x,y,y) if z == 1: c.append(x) else: c.append(y) a = c ans = [a[0],a[0]] a = b #print(a,b) while len(a) > 1: c = collections.deque() while a: x = a.popleft() y = a.popleft() z = query(x,x,y,y) if z == 0: c.append(x) else: c.append(y) a = c ans.extend([a[0],n-1]) #print(ans) ans = list(map(lambda x:x+1,ans)) print('!',*ans) #1 3 4 2