結果

問題 No.515 典型LCP
ユーザー mkawa2mkawa2
提出日時 2023-02-28 16:50:01
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,358 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 86,832 KB
実行使用メモリ 96,844 KB
最終ジャッジ日時 2023-10-13 23:43:27
合計ジャッジ時間 7,791 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 741 ms
93,836 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 75 ms
71,040 KB
testcase_04 AC 73 ms
71,276 KB
testcase_05 AC 333 ms
82,928 KB
testcase_06 AC 333 ms
82,892 KB
testcase_07 AC 332 ms
82,844 KB
testcase_08 AC 333 ms
83,024 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 673 ms
82,272 KB
testcase_16 AC 683 ms
82,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# inf = (1 << 31)-1
# md = 10**9+7
md = 998244353

base = 34
mod = 9999971

def hash_arr(s):
    h = 0
    hh = [0]*(len(s)+1)
    for i, c in enumerate(s):
        c = ord(c)-97
        h = (h*base+c)%mod
        hh[i+1] = h
    return hh

n = II()
ss = []
for _ in range(n): ss.append(hash_arr(SI()))
m, x, d = LI()

ans = 0
for _ in range(m):
    i = (x//(n-1))+1
    j = (x%(n-1))+1
    if i > j:
        i, j = j, i
    else:
        j += 1
    x = (x+d)%(n*(n-1))
    si = ss[i-1]
    sj = ss[j-1]
    l, r = 0, min(len(si), len(sj))+1
    while l+1 < r:
        c = (l+r)//2
        if si[c] == sj[c]:
            l = c
        else:
            r = c
    ans += l

print(ans)
0