結果

問題 No.1994 Confusing Name
ユーザー 👑 rin204rin204
提出日時 2022-07-01 21:39:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 477 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 1,118 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 90,344 KB
最終ジャッジ日時 2023-08-17 09:05:42
合計ジャッジ時間 10,102 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
76,368 KB
testcase_01 AC 76 ms
76,384 KB
testcase_02 AC 77 ms
76,592 KB
testcase_03 AC 71 ms
71,540 KB
testcase_04 AC 69 ms
71,328 KB
testcase_05 AC 103 ms
76,948 KB
testcase_06 AC 107 ms
78,436 KB
testcase_07 AC 96 ms
77,500 KB
testcase_08 AC 103 ms
77,092 KB
testcase_09 AC 105 ms
76,884 KB
testcase_10 AC 103 ms
76,880 KB
testcase_11 AC 101 ms
77,020 KB
testcase_12 AC 397 ms
88,604 KB
testcase_13 AC 467 ms
89,920 KB
testcase_14 AC 443 ms
89,904 KB
testcase_15 AC 417 ms
86,180 KB
testcase_16 AC 429 ms
85,756 KB
testcase_17 AC 428 ms
85,556 KB
testcase_18 AC 467 ms
90,332 KB
testcase_19 AC 471 ms
90,344 KB
testcase_20 AC 477 ms
89,952 KB
testcase_21 AC 158 ms
80,508 KB
testcase_22 AC 143 ms
78,296 KB
testcase_23 AC 417 ms
88,748 KB
testcase_24 AC 410 ms
88,552 KB
testcase_25 AC 294 ms
84,156 KB
testcase_26 AC 199 ms
81,348 KB
testcase_27 AC 384 ms
86,904 KB
testcase_28 AC 367 ms
85,100 KB
testcase_29 AC 125 ms
78,312 KB
testcase_30 AC 403 ms
86,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
T = []
se = set()
for _ in range(n):
    S = input()
    lst = [ord(s) - 96 for s in S]
    tot = 0
    for l in lst:
        tot *= 26
        tot += l
    se.add(tot)
    T.append(lst)

for lst in T:
    ans = 0
    times = 1
    tot = 0
    for l in lst:
        tot *= 26
        tot += l
    se.add(tot)
    for l in lst[::-1]:
        tot -= times * l
        for j in range(1, 27):
            if j == l:
                pass
            else:
                tot += times * j
                if tot in se:
                    ans += 1
                tot -= times * j
        tot += times * l
        times *= 26
    print(ans)
0