結果

問題 No.1994 Confusing Name
ユーザー terasaterasa
提出日時 2022-07-02 12:36:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 751 ms / 2,000 ms
コード長 1,287 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 93,920 KB
最終ジャッジ日時 2023-08-18 03:30:26
合計ジャッジ時間 15,063 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 157 ms
79,664 KB
testcase_01 AC 157 ms
79,164 KB
testcase_02 AC 153 ms
79,404 KB
testcase_03 AC 150 ms
78,304 KB
testcase_04 AC 148 ms
78,288 KB
testcase_05 AC 171 ms
81,472 KB
testcase_06 AC 176 ms
81,588 KB
testcase_07 AC 169 ms
81,532 KB
testcase_08 AC 173 ms
81,284 KB
testcase_09 AC 178 ms
81,532 KB
testcase_10 AC 174 ms
81,288 KB
testcase_11 AC 176 ms
81,960 KB
testcase_12 AC 639 ms
93,624 KB
testcase_13 AC 751 ms
93,440 KB
testcase_14 AC 709 ms
93,800 KB
testcase_15 AC 727 ms
89,804 KB
testcase_16 AC 634 ms
88,828 KB
testcase_17 AC 726 ms
89,840 KB
testcase_18 AC 751 ms
93,920 KB
testcase_19 AC 747 ms
93,496 KB
testcase_20 AC 751 ms
93,696 KB
testcase_21 AC 273 ms
83,124 KB
testcase_22 AC 226 ms
82,304 KB
testcase_23 AC 675 ms
93,424 KB
testcase_24 AC 642 ms
93,532 KB
testcase_25 AC 513 ms
87,796 KB
testcase_26 AC 319 ms
84,240 KB
testcase_27 AC 612 ms
92,428 KB
testcase_28 AC 556 ms
88,740 KB
testcase_29 AC 211 ms
82,044 KB
testcase_30 AC 613 ms
89,720 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