結果

問題 No.1994 Confusing Name
ユーザー FromBooskaFromBooska
提出日時 2023-08-03 11:36:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 699 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 142,188 KB
最終ジャッジ日時 2024-04-21 09:28:37
合計ジャッジ時間 12,498 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
54,328 KB
testcase_01 AC 53 ms
54,692 KB
testcase_02 AC 51 ms
53,940 KB
testcase_03 AC 52 ms
54,024 KB
testcase_04 AC 53 ms
54,248 KB
testcase_05 AC 88 ms
71,924 KB
testcase_06 AC 119 ms
77,624 KB
testcase_07 AC 66 ms
64,560 KB
testcase_08 AC 104 ms
77,268 KB
testcase_09 AC 109 ms
77,508 KB
testcase_10 AC 86 ms
72,712 KB
testcase_11 AC 86 ms
72,588 KB
testcase_12 AC 519 ms
121,992 KB
testcase_13 AC 606 ms
139,272 KB
testcase_14 AC 627 ms
140,044 KB
testcase_15 AC 530 ms
142,128 KB
testcase_16 AC 483 ms
125,904 KB
testcase_17 AC 512 ms
128,040 KB
testcase_18 AC 688 ms
141,832 KB
testcase_19 AC 699 ms
141,808 KB
testcase_20 AC 682 ms
142,188 KB
testcase_21 AC 212 ms
94,592 KB
testcase_22 AC 147 ms
82,292 KB
testcase_23 AC 621 ms
133,124 KB
testcase_24 AC 609 ms
128,404 KB
testcase_25 AC 408 ms
113,664 KB
testcase_26 AC 259 ms
102,428 KB
testcase_27 AC 532 ms
128,200 KB
testcase_28 AC 425 ms
114,620 KB
testcase_29 AC 138 ms
81,576 KB
testcase_30 AC 442 ms
116,816 KB
権限があれば一括ダウンロードができます

ソースコード

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