結果
| 問題 | No.2715 Unique Chimatagram | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-04-10 15:08:00 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,056 bytes | 
| コンパイル時間 | 243 ms | 
| コンパイル使用メモリ | 82,564 KB | 
| 実行使用メモリ | 79,232 KB | 
| 最終ジャッジ日時 | 2024-10-02 16:55:31 | 
| 合計ジャッジ時間 | 7,184 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 35 WA * 5 | 
ソースコード
from collections import Counter
from string import ascii_lowercase
def main():
    N = int(input())
    S = [input() for _ in range(N)]
    S_ctrs = list(map(Counter, S))
    S_sorted = list(map(lambda elm: "".join(sorted(elm)), S))
    S_cand = set()
    S_sorted_ctr = Counter(S_sorted)
    for sort_elm, elm in zip(S_sorted, S):
        if S_sorted_ctr[sort_elm] == 1:
            S_cand.add(elm)
    if not S_cand:
        print(-1)
        return
    for elm in S_cand:
        for add_letter in ascii_lowercase:
            tmp_ctr = Counter(elm)
            tmp_ctr[add_letter] += 1
            for other_elm, other_ctr in zip(S, S_ctrs):
                if other_elm == elm:
                    continue
                tmp_ctr.subtract(other_ctr)
                tmp_ctr_ctr = Counter(tmp_ctr.values())
                if set(tmp_ctr_ctr).issubset({0, 1}) and tmp_ctr_ctr[1] == 1:
                    break
            else:
                print(elm + add_letter)
                return
    print(-1)
if __name__ == "__main__":
    main()
            
            
            
        