結果

問題 No.2715 Unique Chimatagram
ユーザー 👑 KA37RI
提出日時 2024-04-05 21:38:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 127 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 88,880 KB
最終ジャッジ日時 2024-10-01 01:53:08
合計ジャッジ時間 5,445 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #

def ctoi(c):
	return ord(c) - ord("a")
	
def itoc(i):
	return chr(ord("a") + i)

def deg(s):
	res = [0] * 26
	for c in s:
		res[ctoi(c)] += 1
	return tuple(res)
	
n = int(input())
ss = [input() for _ in range(n)]

cnt = {}
for s in ss:
	for c in "abcdefghijklmnopqrstuvwxyz":
		t = s + c
		dt = deg(t)
		if dt in cnt:
			cnt[dt] += 1
		else:
			cnt[dt] = 1
			
ans = "-1"
for dt in cnt:
	if cnt[dt] == 1:
		t = "".join(itoc(i) * dt[i] for i in range(26))
		ans = t
		break
	
print(ans)
0