結果

問題 No.1859 ><<<
ユーザー 👑 H20H20
提出日時 2022-02-27 20:35:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 852 bytes
コンパイル時間 1,837 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 157,712 KB
最終ジャッジ日時 2023-09-19 07:55:22
合計ジャッジ時間 14,594 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,280 KB
testcase_01 AC 72 ms
71,048 KB
testcase_02 AC 74 ms
71,260 KB
testcase_03 AC 73 ms
71,360 KB
testcase_04 AC 247 ms
156,368 KB
testcase_05 AC 310 ms
157,568 KB
testcase_06 AC 231 ms
157,628 KB
testcase_07 AC 225 ms
157,712 KB
testcase_08 AC 230 ms
157,516 KB
testcase_09 AC 231 ms
157,584 KB
testcase_10 AC 112 ms
87,772 KB
testcase_11 AC 167 ms
106,676 KB
testcase_12 AC 157 ms
116,168 KB
testcase_13 AC 130 ms
102,352 KB
testcase_14 AC 173 ms
110,256 KB
testcase_15 AC 208 ms
139,516 KB
testcase_16 AC 221 ms
146,564 KB
testcase_17 AC 184 ms
114,204 KB
testcase_18 AC 221 ms
146,236 KB
testcase_19 AC 186 ms
110,940 KB
testcase_20 AC 208 ms
140,012 KB
testcase_21 AC 219 ms
149,408 KB
testcase_22 AC 216 ms
146,616 KB
testcase_23 AC 208 ms
139,264 KB
testcase_24 AC 217 ms
149,360 KB
testcase_25 AC 226 ms
146,348 KB
testcase_26 AC 214 ms
140,268 KB
testcase_27 AC 229 ms
146,224 KB
testcase_28 AC 222 ms
145,520 KB
testcase_29 AC 219 ms
145,420 KB
testcase_30 AC 209 ms
139,208 KB
testcase_31 AC 211 ms
139,380 KB
testcase_32 AC 226 ms
149,328 KB
testcase_33 AC 214 ms
139,500 KB
testcase_34 AC 215 ms
145,792 KB
testcase_35 AC 224 ms
149,608 KB
testcase_36 AC 227 ms
149,492 KB
testcase_37 AC 214 ms
139,964 KB
testcase_38 AC 225 ms
150,028 KB
testcase_39 AC 223 ms
149,572 KB
testcase_40 AC 217 ms
149,200 KB
testcase_41 AC 218 ms
149,368 KB
testcase_42 AC 207 ms
139,372 KB
testcase_43 AC 217 ms
146,368 KB
testcase_44 AC 216 ms
146,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class RollingHash():
    def __init__(self, s, base, mod):
        self.mod = mod
        self.pw = pw = [1]*(len(s)+1)

        l = len(s)
        self.h = h = [0]*(l+1)

        v = 0
        for i in range(l):
            h[i+1] = v = (v * base + ord(s[i])) % mod
        v = 1
        for i in range(l):
            pw[i+1] = v = v * base % mod
    def get(self, l, r):
        return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

base = 37; mod = 10**9 + 9

N = int(input())
A = list(map(int, input().split())) 
A = A+[A[0]]
S = input()
L = []
for i in range(N):
    if A[i]<A[i+1]:
        L.append('<')
    else:
        L.append('>')
L = ''.join(map(str, L))*2
SRH = RollingHash(S,base,mod)
LRH = RollingHash(L,base,mod)
m = SRH.get(0,len(S))
for i in range(N):
    if m == LRH.get(i,len(S)+i):
        print(i)
        exit()
print(-1)


0