結果

問題 No.1306 Exactly 2 Digits
コンテスト
ユーザー Wizist
提出日時 2020-12-04 00:03:00
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
RE  
実行時間 -
コード長 943 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 379 ms
コンパイル使用メモリ 85,352 KB
実行使用メモリ 823,324 KB
平均クエリ数 1170.76
最終ジャッジ日時 2026-04-01 00:36:31
合計ジャッジ時間 65,240 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 RE * 100 TLE * 12 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#!/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)]

z = {}
for i in range(n, n * n):
	for j in range(n, n * n):
		if i != j:
			p, q = i // n - j // n, i % n - j % n
			if p > q: p, q = q, p
			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
		if a[i] and len(a[i]) == 1: continue
		print("? {} {}".format(i + 1, j + 1), flush=True)
		p, q = read_ints()
		s1, s2 = set(), set()
		for x, y in z[(p, q)]:
			if (not a[i] or x in a[i]) and (not a[j] 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