結果

問題 No.1306 Exactly 2 Digits
ユーザー Wizist
提出日時 2020-12-03 21:53:39
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 989 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,868 KB
実行使用メモリ 392,184 KB
平均クエリ数 266.99
最終ジャッジ日時 2024-07-17 09:09:33
合計ジャッジ時間 44,266 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 RE * 64 TLE * 4 -- * 39
権限があれば一括ダウンロードができます

ソースコード

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 = [None for _ in range(m)]

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

z = {}
for i in range(n, n * n):
	for j in range(n, n * n):
		if i != j:
			p, q = check(i, j)
			if (p, q) not in z: z[(p, q)] = []
			z[(p, q)].append((i, j))
# print(z)

for i in range(m - 1):
	for j in range(i + 1, m):
		if a[i] and a[j] and len(a[i]) == 1 and len(a[j]) == 1: continue
		print("? {} {}".format(i + 1, j + 1), flush=True)
		p, q = read_ints()
		t = z.get((p, q), [set(), set()]);
		s1, s2 = set(), set()
		for x, y in t:
			if (a[i] is None or x in a[i]) and (a[j] is None or y in a[j]):
				s1.add(x); s2.add(y)
		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