結果

問題 No.515 典型LCP
ユーザー mkawa2mkawa2
提出日時 2023-02-28 16:53:19
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,357 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 93,660 KB
最終ジャッジ日時 2023-10-13 23:46:32
合計ジャッジ時間 10,401 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 TLE -
testcase_02 AC 548 ms
83,056 KB
testcase_03 AC 75 ms
71,172 KB
testcase_04 AC 73 ms
71,124 KB
testcase_05 AC 349 ms
82,740 KB
testcase_06 AC 354 ms
82,804 KB
testcase_07 AC 347 ms
82,632 KB
testcase_08 AC 347 ms
82,904 KB
testcase_09 AC 406 ms
83,320 KB
testcase_10 AC 245 ms
83,000 KB
testcase_11 AC 238 ms
83,280 KB
testcase_12 AC 235 ms
83,460 KB
testcase_13 AC 480 ms
82,600 KB
testcase_14 AC 110 ms
82,820 KB
testcase_15 AC 673 ms
82,340 KB
testcase_16 AC 684 ms
82,012 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