結果

問題 No.1996 <><
ユーザー mkawa2mkawa2
提出日時 2022-07-01 22:09:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 649 ms / 2,000 ms
コード長 2,136 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 94,592 KB
最終ジャッジ日時 2024-05-04 16:32:20
合計ジャッジ時間 9,704 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,480 KB
testcase_01 AC 38 ms
52,608 KB
testcase_02 AC 38 ms
52,736 KB
testcase_03 AC 45 ms
59,264 KB
testcase_04 AC 38 ms
52,480 KB
testcase_05 AC 35 ms
52,736 KB
testcase_06 AC 37 ms
52,352 KB
testcase_07 AC 38 ms
52,224 KB
testcase_08 AC 60 ms
71,040 KB
testcase_09 AC 51 ms
60,288 KB
testcase_10 AC 61 ms
69,632 KB
testcase_11 AC 466 ms
85,632 KB
testcase_12 AC 580 ms
94,592 KB
testcase_13 AC 649 ms
94,464 KB
testcase_14 AC 632 ms
93,952 KB
testcase_15 AC 586 ms
91,392 KB
testcase_16 AC 540 ms
89,728 KB
testcase_17 AC 518 ms
91,712 KB
testcase_18 AC 394 ms
86,016 KB
testcase_19 AC 465 ms
87,160 KB
testcase_20 AC 482 ms
86,656 KB
testcase_21 AC 532 ms
89,752 KB
testcase_22 AC 618 ms
92,036 KB
testcase_23 AC 80 ms
77,032 KB
testcase_24 AC 371 ms
85,760 KB
testcase_25 AC 182 ms
80,768 KB
testcase_26 AC 356 ms
83,840 KB
testcase_27 AC 107 ms
77,568 KB
testcase_28 AC 44 ms
60,928 KB
testcase_29 AC 206 ms
80,128 KB
testcase_30 AC 68 ms
76,672 KB
testcase_31 AC 104 ms
77,824 KB
testcase_32 AC 64 ms
76,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = (1 << 63)-1
inf = (1 << 31)-1
md = 10**9+7
# md = 998244353

# 内部で1-indexedに変えるので入力は0-indexedでよい
class BitSum:
    def __init__(self, n):
        self.n = n+1
        self.table = [0]*self.n

    def add(self, i, x):
        i += 1
        while i < self.n:
            self.table[i] += x
            self.table[i] %= md
            i += i & -i

    # [0,i]の和
    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            res %= md
            i -= i & -i
        return res

    # [l,r)の和
    def sumlr(self, l, r):
        if l >= r: return 0
        if l == 0: return self.sum(r-1)
        return self.sum(r-1)-self.sum(l-1)

    # sum(i)>=x となる最小のiを返す
    # xが大きすぎるときは配列の長さnを返す
    def bisect(self, x):
        idx = 0
        d = 1 << (self.n-1).bit_length()-1
        while d:
            if idx+d < self.n and self.table[idx+d] < x:
                x -= self.table[idx+d]
                idx |= d
            d >>= 1
        return idx

n, k = LI()
aa = LI()
s = SI()

dp = [BitSum(n+2) for _ in range(k+2)]
enc = {a: i+1 for i, a in enumerate(sorted(set(aa)))}

for l,a in enumerate(aa):
    a=enc[a]
    for i in range(min(l+1,k+1), 1, -1):
        if s[i-2] == "<":
            dp[i].add(a, dp[i-1].sum(a-1))
        else:
            dp[i].add(a, dp[i-1].sumlr(a+1, n+1))
    dp[1].add(a, 1)

print(dp[k+1].sum(n))
0