結果
| 問題 |
No.2715 Unique Chimatagram
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-04-05 22:20:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 541 ms / 2,000 ms |
| コード長 | 876 bytes |
| コンパイル時間 | 245 ms |
| コンパイル使用メモリ | 82,368 KB |
| 実行使用メモリ | 78,060 KB |
| 最終ジャッジ日時 | 2024-10-01 02:34:43 |
| 合計ジャッジ時間 | 5,273 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 40 |
ソースコード
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 C:
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)
titia