結果

問題 No.2210 equence Squence Seuence
ユーザー ShirotsumeShirotsume
提出日時 2023-02-05 18:59:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,209 ms / 2,000 ms
コード長 2,054 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 137,016 KB
最終ジャッジ日時 2023-09-17 10:15:30
合計ジャッジ時間 14,818 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
76,944 KB
testcase_01 AC 126 ms
76,884 KB
testcase_02 AC 125 ms
77,276 KB
testcase_03 AC 386 ms
92,512 KB
testcase_04 AC 417 ms
95,352 KB
testcase_05 AC 536 ms
102,184 KB
testcase_06 AC 521 ms
99,336 KB
testcase_07 AC 1,020 ms
127,464 KB
testcase_08 AC 130 ms
77,324 KB
testcase_09 AC 139 ms
80,208 KB
testcase_10 AC 139 ms
80,280 KB
testcase_11 AC 136 ms
79,920 KB
testcase_12 AC 141 ms
79,932 KB
testcase_13 AC 1,207 ms
136,656 KB
testcase_14 AC 1,182 ms
136,488 KB
testcase_15 AC 1,198 ms
135,968 KB
testcase_16 AC 1,209 ms
136,200 KB
testcase_17 AC 1,205 ms
137,016 KB
testcase_18 AC 125 ms
77,180 KB
testcase_19 AC 124 ms
77,120 KB
testcase_20 AC 126 ms
77,192 KB
testcase_21 AC 125 ms
77,280 KB
testcase_22 AC 127 ms
77,136 KB
testcase_23 AC 284 ms
127,428 KB
testcase_24 AC 251 ms
119,896 KB
testcase_25 AC 269 ms
124,280 KB
testcase_26 AC 313 ms
134,200 KB
testcase_27 AC 193 ms
95,148 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
from functools import cmp_to_key
class Rollinghash:
    def __init__(self, string, base, mod):
        n = len(string)
        self.__base = base
        self.__mod = mod
        self.__hash = [0]*(n + 1)
        self.__pow = [1]*(n + 1)
        if isinstance(string, str):
            for i, c in enumerate(string):
                o = ord(c) - ord('a') + 1
                self.__hash[i + 1] = (self.__hash[i] * self.__base + o) % self.__mod
                self.__pow[i + 1] = self.__pow[i] * self.__base % self.__mod
        else:
            for i, c in enumerate(string):
                o = c
                self.__hash[i + 1] = (self.__hash[i] * self.__base + o) % self.__mod
                self.__pow[i + 1] = self.__pow[i] * self.__base % self.__mod
        self.pow = self.__pow


   
    def query(self, l, r):
        ret = (self.__hash[r] - self.__hash[l] * self.__pow[r - l]) % self.__mod
        return ret
    def same(self, l1, r1, l2, r2):
        return self.query(l1, r1) == self.query(l2, r2)
import random
n, k = mi()
a = li()
base = random.randint(1, 998244352)
S = Rollinghash(a, base, mod)

def calchash(i, r):
    if r < i:
        return S.query(0,r)
    else:
        return (S.query(0, i) * S.pow[r - i] + S.query(i + 1,r + 1)) % mod

def ele(i, x):
    if x < i:
        return a[x]
    else:
        return a[x + 1]
def cmp(x, y):
    if x == y:
        return 0
    if calchash(x, n - 1) == calchash(y, n - 1):
        return 0
    ng = n - 1
    ok = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if calchash(x, mid) == calchash(y, mid):
            ok = mid
        else:
            ng = mid
    
    if ele(x, ok) < ele(y, ok):
        return -1
    else:
        return 1

p = sorted(list(range(n)), key = cmp_to_key(cmp))
x = p[k - 1]

ans = a[:x] + a[x + 1:]

print(*ans)
0