結果

問題 No.1996 <><
ユーザー sotanishysotanishy
提出日時 2022-07-01 22:28:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,359 ms / 2,000 ms
コード長 1,267 bytes
コンパイル時間 1,066 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 96,672 KB
最終ジャッジ日時 2023-08-17 09:57:51
合計ジャッジ時間 18,612 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,240 KB
testcase_01 AC 75 ms
71,612 KB
testcase_02 AC 74 ms
71,368 KB
testcase_03 AC 91 ms
75,852 KB
testcase_04 AC 75 ms
71,372 KB
testcase_05 AC 75 ms
71,344 KB
testcase_06 AC 74 ms
71,600 KB
testcase_07 AC 77 ms
71,360 KB
testcase_08 AC 97 ms
77,088 KB
testcase_09 AC 84 ms
76,048 KB
testcase_10 AC 96 ms
76,852 KB
testcase_11 AC 637 ms
86,988 KB
testcase_12 AC 1,091 ms
96,280 KB
testcase_13 AC 1,359 ms
96,672 KB
testcase_14 AC 1,345 ms
95,996 KB
testcase_15 AC 1,158 ms
93,112 KB
testcase_16 AC 998 ms
91,392 KB
testcase_17 AC 1,208 ms
92,976 KB
testcase_18 AC 735 ms
86,620 KB
testcase_19 AC 790 ms
88,160 KB
testcase_20 AC 794 ms
87,624 KB
testcase_21 AC 1,044 ms
91,548 KB
testcase_22 AC 1,218 ms
93,636 KB
testcase_23 AC 142 ms
78,760 KB
testcase_24 AC 713 ms
86,928 KB
testcase_25 AC 382 ms
83,044 KB
testcase_26 AC 602 ms
85,352 KB
testcase_27 AC 176 ms
79,240 KB
testcase_28 AC 90 ms
76,444 KB
testcase_29 AC 348 ms
82,156 KB
testcase_30 AC 110 ms
77,660 KB
testcase_31 AC 189 ms
79,416 KB
testcase_32 AC 100 ms
77,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from bisect import bisect_left

class FenwickTree:
    def __init__(self, size):
        self.data = [0] * (size + 1)
        self.size = size

    # i is exclusive
    def prefix_sum(self, i):
        s = 0
        while i > 0:
            s = (s + self.data[i]) % mod
            i -= i & -i
        return s

    def add(self, i, x):
        i += 1
        while i <= self.size:
            self.data[i] = (self.data[i] + x) % mod
            i += i & -i

class Compress:
    def __init__(self, vs):
        self.xs = list(set(vs))
        self.xs.sort()

    def compress(self, x):
        return bisect_left(self.xs, x)

    def decompress(self, i):
        return self.xs[i]

    def size(self):
        return len(self.xs)

N, K = map(int, input().split())
A = list(map(int, input().split()))
s = input().rstrip()
comp = Compress(A)
A = [comp.compress(a) for a in A]
M = comp.size()
mod = 10**9 + 7
dp = [FenwickTree(M) for _ in range(K+1)]
for a in A:
    for k in range(K)[::-1]:
        if s[k] == '<':
            c = dp[k].prefix_sum(a)
            dp[k+1].add(a, c)
        else:
            c = dp[k].prefix_sum(M) - dp[k].prefix_sum(a+1)
            dp[k+1].add(a, c)
    dp[0].add(a, 1)
print(dp[K].prefix_sum(M))
0