結果

問題 No.1306 Exactly 2 Digits
ユーザー Wizist
提出日時 2020-12-03 20:04:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 838 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 81,996 KB
実行使用メモリ 261,040 KB
平均クエリ数 1294.63
最終ジャッジ日時 2024-07-17 08:57:40
合計ジャッジ時間 104,210 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18 RE * 97 TLE * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
#
# No.1306 Exactly 2 Digits
#
import sys, os, math

def read_int(): return int(input())
def read_ints(): return list(map(int, input().split()))

n = read_int()
m = n * n - n
a = [set(range(n, n * n)) for _ in range(n * n - n)]

def check(v1, v2):
	p, q = v1 // n - v2 // n, v1 % n - v2 % n
	return min(p, q), max(p, q)

for i in range(m):
	for j in range(i + 1, m):
		if len(a[i]) <= 1 and len(a[j]) <= 1: continue
		ai, aj = n, j + n
		print("? {} {}".format(i + 1, j + 1), flush=True)
		p, q = read_ints()
		s1, s2 = set(), set()
		for v1 in a[i]:
			for v2 in a[j]:
				if v1 == v2: continue
				pp, qq = check(v1, v2)
				if pp == p and qq == q:
					s1.add(v1); s2.add(v2)
		a[i] = s1; a[j] = s2
		# print(a[i], a[j], file=sys.stderr)

print("! {}".format(" ".join([str(list(x)[0]) for x in a])), flush=True)
0