結果
| 問題 |
No.2715 Unique Chimatagram
|
| コンテスト | |
| ユーザー |
dp_ijk
|
| 提出日時 | 2024-04-05 21:50:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 2,000 ms |
| コード長 | 722 bytes |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 82,500 KB |
| 実行使用メモリ | 82,276 KB |
| 最終ジャッジ日時 | 2024-10-01 02:06:28 |
| 合計ジャッジ時間 | 5,525 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
from collections import Counter
from bisect import bisect_left, bisect_right, insort
def ch_gen(start="a", stop="z"):
for i in range(ord(start), ord(stop) + 1):
yield chr(i)
ABC = [*ch_gen()]
N = int(input())
S = []
for _ in range(N):
s = sorted(input())
S.append(s)
C = Counter()
for s in S:
for ch in ABC:
insort(s, ch)
u = "".join(s)
C[u] += 1
s.remove(ch)
for s in S:
pool = []
for ch in ABC:
insort(s, ch)
u = "".join(s)
pool.append(u)
s.remove(ch)
for u in pool:
C[u] -= 1
if C[u] == 0:
del C[u]
for u in pool:
if C[u] == 0:
print(u)
exit()
for u in pool:
C[u] += 1
print(-1)
dp_ijk