結果
| 問題 |
No.2715 Unique Chimatagram
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-07 12:19:50 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 692 bytes |
| コンパイル時間 | 553 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 73,088 KB |
| 最終ジャッジ日時 | 2024-11-30 05:05:02 |
| 合計ジャッジ時間 | 5,652 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 WA * 5 |
ソースコード
N=int(input())
S=[]
for i in range(N):
s=input(); res=[]
for j in range(len(s)):
res.append(s[j])
S.append(tuple(sorted(res)))
from collections import defaultdict
dd=defaultdict(lambda: 0)
for elm in S:
dd[elm]+=1
new_s=set()
for key in dd:
if dd[key]!=1: continue
new_s.add(key)
S=new_s
if len(S)==0: print(-1)
for tup1 in S:
flag=True
for tup2 in S:
if tup1==tup2: continue
if len(tup1)!=len(tup2): continue
diff=0
j=0
for i in range(len(tup1)):
if j>len(tup2): continue
if tup1[i]!=tup2[j]: diff+=1; j+=1
if diff<=1:
flag=False
if flag:
ans=list(tup1)
ans.append("a")
print("".join(sorted(ans)))
exit()