結果

問題 No.2715 Unique Chimatagram
コンテスト
ユーザー Butterflv
提出日時 2024-05-07 12:19:50
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 692 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 547 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 74,112 KB
最終ジャッジ日時 2026-05-23 21:44:34
合計ジャッジ時間 4,662 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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()
0