結果
問題 |
No.2732 Similar Permutations
|
ユーザー |
|
提出日時 | 2024-04-09 17:20:48 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 684 bytes |
コンパイル時間 | 356 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 636,888 KB |
最終ジャッジ日時 | 2024-10-01 17:57:19 |
合計ジャッジ時間 | 163,958 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 36 TLE * 62 MLE * 2 -- * 1 |
ソースコード
from itertools import permutations from collections import defaultdict N = int(input()) A = list(map(int, input().split())) if N <= 10: d = defaultdict(list) for p in permutations(list(range(1, N + 1))): x = 0 for i in range(N): x ^= A[i] + p[i] d[x].append(p) for c, ps in d.items(): if len(ps) >= 2: print(*ps[0]) print(*ps[1]) exit() exit(print(-1)) P = list(range(1, N + 1)) x = 0 for i in range(N): x ^= A[i] + i + 1 ax = 0 for i in range(10, N): ax ^= A[i] + i + 1 for p in list(permutations(list(range(1, 11))))[1:]: nx = 0 for i in range(10): nx ^= A[i] + p[i] if x == ax ^ nx: print(*P) print(*(list(p) + list(range(11, N + 1)))) exit()