結果
| 問題 | No.2715 Unique Chimatagram | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2024-04-05 22:19:15 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 880 bytes | 
| コンパイル時間 | 340 ms | 
| コンパイル使用メモリ | 82,276 KB | 
| 実行使用メモリ | 77,780 KB | 
| 最終ジャッジ日時 | 2024-10-01 02:33:08 | 
| 合計ジャッジ時間 | 6,089 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 | 
| other | AC * 27 WA * 13 | 
ソースコード
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 CS[j]:
                if C[y]<CS[j][y]:
                    fflag=0
                    break
                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)
            
            
            
        