結果

問題 No.2210 equence Squence Seuence
ユーザー タコイモタコイモ
提出日時 2023-02-11 09:47:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 3,344 bytes
コンパイル時間 245 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 128,380 KB
最終ジャッジ日時 2023-09-22 08:36:58
合計ジャッジ時間 14,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
72,568 KB
testcase_01 AC 101 ms
72,560 KB
testcase_02 AC 103 ms
72,540 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 983 ms
94,368 KB
testcase_07 TLE -
testcase_08 WA -
testcase_09 AC 120 ms
77,748 KB
testcase_10 AC 112 ms
77,100 KB
testcase_11 AC 111 ms
77,120 KB
testcase_12 AC 117 ms
77,436 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 AC 101 ms
72,484 KB
testcase_19 AC 102 ms
72,416 KB
testcase_20 WA -
testcase_21 AC 102 ms
72,564 KB
testcase_22 WA -
testcase_23 AC 678 ms
117,592 KB
testcase_24 AC 548 ms
106,132 KB
testcase_25 AC 620 ms
112,448 KB
testcase_26 AC 796 ms
124,068 KB
testcase_27 AC 321 ms
93,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

base = 37 #こっちはなんでもよい、modはいじれない
mod = 2305843009213693951 #2**61 - 1 制限時間に余裕があり衝突したらこっちを使う
ss = 2**31
sr = 2**30
class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        l = len(s)
        self.pw = pw = [1]*(l+1)
        self.h = h = [0]*(l+1)
        v = 0
        vv = 1
        for i in range(l):
            ad = v % ss
            au = v // ss
            mid = au*base
            midu = mid//sr
            midd = mid%sr
            #小文字のみ
            #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])-96) % mod
            #大文字のみ or 大文字と小文字のみ
            #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])-64) % mod
            #通常
            #h[i+1] = v = (midu+midd*ss+ad*base + ord(s[i])+1) % mod
            #自然数
            h[i+1] = v = (midu+midd*ss+ad*base + s[i]) % mod
            

            ad = vv % ss
            au = vv // ss
            mid = au*base
            midu = mid//sr
            midd = mid%sr
            pw[i+1] = vv = (midu+midd*ss+ad*base)% mod
    #[l,r)
    def get(self, l, r):
        a = self.h[l]
        b = self.pw[r-l]
        au = a // ss
        ad = a % ss
        bu = b // ss
        bd = b % ss
        mid = au*bd + ad*bu
        midu = mid//sr
        midd = mid%sr
        return (self.h[r] - au*bu*2-midu-midd*ss-ad*bd) % self.mod
import sys
#sys.setrecursionlimit(500000)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def TI(): return tuple(map(int,sys.stdin.readline().rstrip().split()))
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip())
#for i, pi in enumerate(p):
from collections import defaultdict,deque
import bisect
import itertools
dic = defaultdict(int)
d = deque()

N,K = MI()
A = LI()
S = RollingHash(A,base,mod)
#https://aotamasaki.hatenablog.com/entry/meguru_bisect
#arg桁

def is_ok(arg,x,y):
  if arg == 0:
    return True
  if arg == N:
    return False
  if arg <= x and arg <= y:
    return True
  
  if arg < x:
    X = S.get(0,arg)
  else:
    X = ((S.get(0,x)*S.pw[N-1-x])%mod+S.get(x+1,arg+1))%mod
  if arg < y:
    Y = S.get(0,arg)
  else:
    Y = ((S.get(0,y)*S.pw[N-1-y])%mod+S.get(y+1,arg+1))%mod  
  
  if X == Y:
    return True
  else:
    return False
        
def meguru_bisect(ng, ok,s,t):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid,s,t):
            ok = mid
        else:
            ng = mid
    return ok
def cmp(x,y):
  h = meguru_bisect(N,0,x,y)
  
  if h == N-1:
    return 0

  if x > h:
    f = A[h]
  else:
    f = A[h+1]
  if y > h:
    ff = A[h]
  else:
    ff = A[h+1]
  if f < ff:
    return -1
  elif f == ff:
    return 0
  else:
    return 1
    
  
D = list(range(N))
from functools import cmp_to_key
p = sorted(D, key = cmp_to_key(cmp))
x = p[K - 1]

ans = A[:x] + A[x + 1:]
print(*ans)
0