結果

問題 No.1994 Confusing Name
ユーザー FromBooska
提出日時 2023-08-03 11:36:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 430 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 82,824 KB
実行使用メモリ 142,052 KB
最終ジャッジ日時 2024-10-13 08:21:21
合計ジャッジ時間 8,506 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二重ループは不可能だがSの長さは小さい
# よってSを1文字ずつハテナ変形した文字列を作って数える
# 自身のダミーを数えないように注意

N = int(input())
from collections import defaultdict
dic = defaultdict(int)
S = []
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(temp, dic)

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