結果

問題 No.2715 Unique Chimatagram
コンテスト
ユーザー koheijkt
提出日時 2026-06-03 21:30:36
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 717 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 201 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 97,792 KB
最終ジャッジ日時 2026-06-03 21:30:44
合計ジャッジ時間 5,381 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
N = int(input())
dd = defaultdict(int)
for i in range(N):
    s = input()
    cnt = [0]*26
    for ss in s:
        cnt[ord(ss) - 97] += 1
    dd[tuple(cnt)] += 1

chimatagram = defaultdict(int)
for k, v in dd.items():
    cnt = list(k) # list化する
    for i in range(26):
        cnt[i] += 1
        chimatagram[tuple(cnt)] += v
        cnt[i] -= 1

# ちまたぐらむの中で生成数1のものがあればそれを答えとする

for k, v in chimatagram.items():
    if v == 1:
        ans = []
        # k = (0, 1, ..., 1)
        for i in range(26):
            for _ in range(k[i]):
                ans.append(chr(97 + i))
        exit(print(''.join(ans)))
print(-1)
0