結果

問題 No.1994 Confusing Name
ユーザー 👑 rin204
提出日時 2022-07-01 21:39:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 88,788 KB
最終ジャッジ日時 2024-11-26 04:23:59
合計ジャッジ時間 8,447 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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