結果

問題 No.1994 Confusing Name
ユーザー terasaterasa
提出日時 2022-07-02 12:36:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 2,000 ms
コード長 1,287 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 90,496 KB
最終ジャッジ日時 2024-05-05 10:01:36
合計ジャッジ時間 12,216 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
70,912 KB
testcase_01 AC 70 ms
69,760 KB
testcase_02 AC 68 ms
69,120 KB
testcase_03 AC 63 ms
66,432 KB
testcase_04 AC 64 ms
66,304 KB
testcase_05 AC 92 ms
77,976 KB
testcase_06 AC 97 ms
78,156 KB
testcase_07 AC 88 ms
78,080 KB
testcase_08 AC 95 ms
77,932 KB
testcase_09 AC 99 ms
78,464 KB
testcase_10 AC 96 ms
78,032 KB
testcase_11 AC 95 ms
78,208 KB
testcase_12 AC 552 ms
89,784 KB
testcase_13 AC 663 ms
89,856 KB
testcase_14 AC 649 ms
90,352 KB
testcase_15 AC 657 ms
86,444 KB
testcase_16 AC 572 ms
85,872 KB
testcase_17 AC 667 ms
86,376 KB
testcase_18 AC 667 ms
90,496 KB
testcase_19 AC 661 ms
90,248 KB
testcase_20 AC 663 ms
90,424 KB
testcase_21 AC 201 ms
79,752 KB
testcase_22 AC 158 ms
78,976 KB
testcase_23 AC 611 ms
90,112 KB
testcase_24 AC 577 ms
89,592 KB
testcase_25 AC 439 ms
84,284 KB
testcase_26 AC 247 ms
80,820 KB
testcase_27 AC 552 ms
88,648 KB
testcase_28 AC 489 ms
84,992 KB
testcase_29 AC 137 ms
78,720 KB
testcase_30 AC 523 ms
86,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect
import string
import copy

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N = int(input())
S = [input()[:-1] for _ in range(N)]
H = []
for s in S:
    acc = 0
    for j in range(len(s)):
        acc += pow(27, j) * (ord(s[-(j + 1)]) - ord('a') + 1)
    H.append(acc)
Hs = set(H)

for i in range(N):
    s = S[i]
    ans = 0
    for j in range(len(s)):
        for c in string.ascii_lowercase:
            if s[j] == c:
                continue
            d = pow(27, len(s) - 1 - j) * (ord(c) - ord(s[j]))
            if H[i] + d in Hs:
                ans += 1
    print(ans)
0