結果

問題 No.515 典型LCP
ユーザー mkawa2mkawa2
提出日時 2023-08-18 17:52:28
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,357 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 93,736 KB
最終ジャッジ日時 2023-08-18 17:52:47
合計ジャッジ時間 11,725 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 546 ms
83,112 KB
testcase_03 AC 83 ms
71,464 KB
testcase_04 AC 81 ms
71,236 KB
testcase_05 AC 385 ms
83,048 KB
testcase_06 AC 361 ms
83,100 KB
testcase_07 AC 357 ms
83,264 KB
testcase_08 AC 364 ms
83,052 KB
testcase_09 AC 409 ms
83,384 KB
testcase_10 AC 256 ms
83,548 KB
testcase_11 AC 249 ms
83,488 KB
testcase_12 AC 246 ms
83,580 KB
testcase_13 AC 491 ms
83,128 KB
testcase_14 AC 129 ms
83,200 KB
testcase_15 AC 693 ms
82,412 KB
testcase_16 AC 706 ms
82,476 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))
    while l+1 < r:
        c = (l+r)//2
        if si[c] == sj[c]:
            l = c
        else:
            r = c
    ans += l

print(ans)
0