結果

問題 No.1994 Confusing Name
ユーザー FromBooska
提出日時 2024-03-21 18:15:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 2,000 ms
コード長 462 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 142,284 KB
最終ジャッジ日時 2024-09-30 10:10:59
合計ジャッジ時間 7,656 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二重ループはできない、各Siの一字替えを辞書化

from collections import defaultdict

N = int(input())
S = []
dic = defaultdict(int)
for i in range(N):
    s = input()
    S.append(s)
    for j in range(len(s)):
        temp = s[:j]+'*'+s[j+1:]
        dic[temp] += 1
#print(S)
#print(dic)

for s in S:
    count = 0
    for j in range(len(s)):
        temp = s[:j]+'*'+s[j+1:]
        count += dic[temp]
    ans = count-len(s)
    print(ans)
0