結果
| 問題 | No.2715 Unique Chimatagram | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2024-04-05 22:18:11 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 877 bytes | 
| コンパイル時間 | 480 ms | 
| コンパイル使用メモリ | 81,872 KB | 
| 実行使用メモリ | 84,184 KB | 
| 最終ジャッジ日時 | 2024-10-01 02:32:34 | 
| 合計ジャッジ時間 | 9,358 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 TLE * 1 -- * 3 | 
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
n=int(input())
S=[sorted(input().strip()) for i in range(n)]
CS=[]
for i in range(n):
    CS.append(Counter(S[i]))
for i in range(n):
    if i+1<n and S[i]==S[i+1]:
        continue
    if i-1>=0 and S[i]==S[i-1]:
        continue
    for x in "abcdefghijklmnopqrstuvwxyz":
        T=S[i]+[x]
        C=Counter(T)
        flag=1
        for j in range(n):
            if i==j:
                continue
            count=0
            fflag=1
            for y in "abcdefghijklmnopqrstuvwxyz":
                if C[y]<CS[j][y]:
                    fflag=0
                else:
                    count+=C[y]-CS[j][y]
            if fflag==1 and count==1:
                flag=0
                break
        if flag==1:
            print("".join(T))
            exit()
        
        
print(-1)
            
            
            
        