結果
| 問題 |
No.2732 Similar Permutations
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-27 14:44:02 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 915 bytes |
| コンパイル時間 | 496 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 107,008 KB |
| 最終ジャッジ日時 | 2024-11-15 17:33:03 |
| 合計ジャッジ時間 | 69,777 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 WA * 79 |
ソースコード
from itertools import permutations
def answer(p):
for pi in p:
print(pi + 1, end=" ")
print()
def solve_less10():
hm = dict()
for p in permutations(range(n), n):
xor = 0
for i in range(n):
xor ^= p[i] + a[i]
if xor in hm:
answer(hm[xor])
answer(p)
exit()
hm[xor] = p
print(-1)
def solve_more10():
xor_base = 0
for i in range(10, n):
xor_base ^= i + a[i]
hm = dict()
for p in permutations(range(10), 10):
xor = 0
for i in range(10):
xor ^= p[i] + a[i]
if xor_base ^ xor in hm:
answer(hm[xor] + tuple(range(10, n)))
answer(p + tuple(range(10, n)))
exit()
hm[xor] = p
print(-1)
n = int(input())
a = list(map(int, input().split()))
if n < 10:
solve_less10()
else:
solve_more10()