結果

問題 No.958 たぷりすたべる (回文)
ユーザー mkawa2mkawa2
提出日時 2022-06-24 11:15:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,272 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 83,072 KB
最終ジャッジ日時 2024-04-25 15:59:05
合計ジャッジ時間 8,035 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,600 KB
testcase_01 AC 36 ms
52,336 KB
testcase_02 AC 35 ms
53,132 KB
testcase_03 AC 35 ms
54,352 KB
testcase_04 AC 37 ms
52,956 KB
testcase_05 AC 33 ms
53,560 KB
testcase_06 AC 35 ms
53,192 KB
testcase_07 AC 36 ms
52,400 KB
testcase_08 AC 35 ms
53,240 KB
testcase_09 AC 35 ms
53,280 KB
testcase_10 AC 36 ms
53,284 KB
testcase_11 AC 37 ms
52,744 KB
testcase_12 AC 36 ms
53,660 KB
testcase_13 AC 35 ms
54,100 KB
testcase_14 WA -
testcase_15 AC 36 ms
53,880 KB
testcase_16 AC 36 ms
53,784 KB
testcase_17 AC 37 ms
53,188 KB
testcase_18 AC 39 ms
52,956 KB
testcase_19 AC 39 ms
53,008 KB
testcase_20 AC 39 ms
53,192 KB
testcase_21 AC 38 ms
54,876 KB
testcase_22 AC 39 ms
53,776 KB
testcase_23 AC 38 ms
54,256 KB
testcase_24 AC 40 ms
53,192 KB
testcase_25 AC 38 ms
53,748 KB
testcase_26 AC 37 ms
53,012 KB
testcase_27 AC 88 ms
76,768 KB
testcase_28 AC 80 ms
76,236 KB
testcase_29 AC 77 ms
76,276 KB
testcase_30 AC 77 ms
76,124 KB
testcase_31 AC 80 ms
76,260 KB
testcase_32 AC 80 ms
76,332 KB
testcase_33 AC 81 ms
76,400 KB
testcase_34 AC 81 ms
76,280 KB
testcase_35 AC 79 ms
76,472 KB
testcase_36 AC 85 ms
76,384 KB
testcase_37 AC 89 ms
76,440 KB
testcase_38 AC 88 ms
76,516 KB
testcase_39 AC 90 ms
76,488 KB
testcase_40 AC 93 ms
76,068 KB
testcase_41 AC 88 ms
76,180 KB
testcase_42 AC 85 ms
76,196 KB
testcase_43 AC 81 ms
76,848 KB
testcase_44 AC 88 ms
76,416 KB
testcase_45 AC 88 ms
76,336 KB
testcase_46 AC 92 ms
76,796 KB
testcase_47 AC 157 ms
80,812 KB
testcase_48 AC 165 ms
82,688 KB
testcase_49 AC 169 ms
82,356 KB
testcase_50 AC 163 ms
83,072 KB
testcase_51 AC 179 ms
82,680 KB
testcase_52 AC 199 ms
82,648 KB
testcase_53 AC 179 ms
82,276 KB
testcase_54 AC 183 ms
82,536 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

def Manacher(s):
    i = j = 0
    res = [-1]*len(s)
    while i < len(s):
        while i-j >= 0 and i+j < len(s) and s[i-j] == s[i+j]: j += 1
        res[i] = j
        k = 1
        while i-k >= 0 and k+res[i-k] < j:
            res[i+k] = res[i-k]
            k += 1
        i += k
        j -= k
    return res

n, k, q = LI()
s = SI()
ll = Manacher(s*3)

for _ in range(q):
    a = II()-1
    j, i = divmod(a, n)
    if j == k-1: i += 2*n
    elif j: i += n
    ans = ll[i]*2-1
    if ans >= n: ans = min(a*2+1, (n*k-a)*2-1)
    print(ans)
0