結果

問題 No.2715 Unique Chimatagram
コンテスト
ユーザー 👑 KA37RI
提出日時 2024-04-05 21:38:33
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 80 ms / 2,000 ms
+ 433µs
コード長 485 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 97 ms
コンパイル使用メモリ 64,528 KB
実行使用メモリ 75,948 KB
最終ジャッジ日時 2026-11-08 11:54:35
合計ジャッジ時間 6,826 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 42
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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