結果
問題 |
No.233 めぐるはめぐる (3)
|
ユーザー |
👑 |
提出日時 | 2022-07-12 14:21:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 267 ms / 1,000 ms |
コード長 | 1,173 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 82,012 KB |
実行使用メモリ | 86,684 KB |
最終ジャッジ日時 | 2024-06-23 11:30:43 |
合計ジャッジ時間 | 5,657 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
import itertools def popcount(x): x = x - ((x >> 1) & 0x55555555) x = (x & 0x33333333) + ((x >> 2) & 0x33333333) x = (x + (x >> 4)) & 0x0f0f0f0f x += x >> 8 x += x >> 16 return x & 0x0000003f S = "iaaeuu" bo = set() for ss in itertools.permutations(S): bo.add("".join(ss)) S = "nbmgr" shi = set() for ss in itertools.permutations(S): shi.add("".join(ss)) bits = [] for bit in range(1 << 11): pc = popcount(bit) if pc != 5: continue if bit >> 10 & 1: continue ok = True for i in range(10): if bit >> i & 1 and bit >> (i + 1) & 1: ok = False break if ok: bits.append(bit) se = set() for S in bo: for T in shi: for bit in bits: X = [] sp = 0 tp = 0 for i in range(11): if bit >> i & 1: X.append(T[tp]) tp += 1 else: X.append(S[sp]) sp += 1 se.add("".join(X)) n = int(input()) for _ in range(n): S = input() se.remove(S) for s in se: print(s) exit() print("NO")