結果

問題 No.2210 equence Squence Seuence
ユーザー ShirotsumeShirotsume
提出日時 2023-02-05 19:31:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,179 ms / 2,000 ms
コード長 1,956 bytes
コンパイル時間 512 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 139,048 KB
最終ジャッジ日時 2023-09-17 10:28:16
合計ジャッジ時間 14,525 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
77,344 KB
testcase_01 AC 128 ms
77,264 KB
testcase_02 AC 129 ms
77,112 KB
testcase_03 AC 389 ms
92,284 KB
testcase_04 AC 402 ms
94,660 KB
testcase_05 AC 525 ms
103,328 KB
testcase_06 AC 498 ms
99,284 KB
testcase_07 AC 1,008 ms
127,716 KB
testcase_08 AC 131 ms
77,112 KB
testcase_09 AC 141 ms
79,720 KB
testcase_10 AC 140 ms
79,680 KB
testcase_11 AC 141 ms
79,712 KB
testcase_12 AC 144 ms
79,996 KB
testcase_13 AC 1,165 ms
136,032 KB
testcase_14 AC 1,158 ms
138,088 KB
testcase_15 AC 1,148 ms
139,048 KB
testcase_16 AC 1,179 ms
137,224 KB
testcase_17 AC 1,145 ms
137,384 KB
testcase_18 AC 131 ms
77,208 KB
testcase_19 AC 128 ms
77,228 KB
testcase_20 AC 126 ms
77,264 KB
testcase_21 AC 128 ms
77,104 KB
testcase_22 AC 128 ms
77,264 KB
testcase_23 AC 378 ms
127,376 KB
testcase_24 AC 332 ms
119,848 KB
testcase_25 AC 356 ms
124,824 KB
testcase_26 AC 423 ms
134,340 KB
testcase_27 AC 238 ms
94,988 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):
    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