結果

問題 No.1859 ><<<
ユーザー ShirotsumeShirotsume
提出日時 2021-11-26 12:55:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 183 ms / 2,000 ms
コード長 962 bytes
コンパイル時間 108 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 43,688 KB
最終ジャッジ日時 2023-09-17 22:17:56
合計ジャッジ時間 8,726 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,768 KB
testcase_01 AC 17 ms
7,952 KB
testcase_02 AC 16 ms
7,784 KB
testcase_03 AC 16 ms
7,828 KB
testcase_04 AC 168 ms
42,940 KB
testcase_05 AC 168 ms
43,024 KB
testcase_06 AC 168 ms
42,948 KB
testcase_07 AC 170 ms
42,904 KB
testcase_08 AC 169 ms
43,044 KB
testcase_09 AC 171 ms
42,904 KB
testcase_10 AC 43 ms
14,292 KB
testcase_11 AC 110 ms
28,000 KB
testcase_12 AC 101 ms
25,520 KB
testcase_13 AC 66 ms
18,828 KB
testcase_14 AC 115 ms
29,616 KB
testcase_15 AC 151 ms
39,096 KB
testcase_16 AC 167 ms
41,628 KB
testcase_17 AC 127 ms
32,536 KB
testcase_18 AC 165 ms
41,636 KB
testcase_19 AC 126 ms
32,796 KB
testcase_20 AC 150 ms
38,136 KB
testcase_21 AC 166 ms
42,160 KB
testcase_22 AC 157 ms
40,596 KB
testcase_23 AC 147 ms
39,176 KB
testcase_24 AC 162 ms
43,296 KB
testcase_25 AC 167 ms
41,592 KB
testcase_26 AC 156 ms
38,328 KB
testcase_27 AC 167 ms
41,596 KB
testcase_28 AC 160 ms
41,040 KB
testcase_29 AC 161 ms
38,896 KB
testcase_30 AC 156 ms
39,120 KB
testcase_31 AC 155 ms
39,148 KB
testcase_32 AC 176 ms
43,688 KB
testcase_33 AC 159 ms
38,960 KB
testcase_34 AC 161 ms
41,084 KB
testcase_35 AC 175 ms
42,284 KB
testcase_36 AC 174 ms
42,124 KB
testcase_37 AC 160 ms
38,084 KB
testcase_38 AC 183 ms
42,720 KB
testcase_39 AC 177 ms
42,204 KB
testcase_40 AC 160 ms
43,312 KB
testcase_41 AC 166 ms
42,252 KB
testcase_42 AC 146 ms
38,956 KB
testcase_43 AC 159 ms
40,392 KB
testcase_44 AC 159 ms
40,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def partial_match_table(word):
    table = [0] * (len(word) + 1)
    table[0] = -1
    i, j = 0, 1

    while j < len(word):
        matched = word[i] == word[j]

        if not matched and i > 0:
            i = table[i]
        else:
            if matched:
                i += 1
            j += 1
            table[j] = i

    return table
    
def kmp_search(text, word):
    table = partial_match_table(word)
    i, p = 0, 0

    while i < len(text) and p < len(word):
        if text[i] == word[p]:
            i += 1
            p += 1
        elif p == 0:
            i += 1
        else:
            p = table[p]

    return (-1, i - p)[p == len(word)]

def solve(n, a, s):
    a = a + a
    t = []
    for i in range(2 * n - 1):
        if a[i] < a[i + 1]:
            t.append('<')
        else:
            t.append('>')
    t = ''.join(t)
    return t.find(s)

n = int(input())
a = list(map(int,input().split()))
s = input()

print(solve(n, a, s))
0