結果

問題 No.1996 <><
ユーザー mkawa2mkawa2
提出日時 2022-07-01 22:09:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 674 ms / 2,000 ms
コード長 2,136 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 96,236 KB
最終ジャッジ日時 2023-08-17 09:41:14
合計ジャッジ時間 11,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,560 KB
testcase_01 AC 72 ms
71,176 KB
testcase_02 AC 72 ms
71,368 KB
testcase_03 AC 76 ms
75,932 KB
testcase_04 AC 70 ms
71,032 KB
testcase_05 AC 70 ms
71,440 KB
testcase_06 AC 71 ms
71,396 KB
testcase_07 AC 71 ms
71,440 KB
testcase_08 AC 92 ms
76,716 KB
testcase_09 AC 77 ms
76,224 KB
testcase_10 AC 90 ms
76,548 KB
testcase_11 AC 483 ms
86,548 KB
testcase_12 AC 626 ms
96,236 KB
testcase_13 AC 674 ms
95,984 KB
testcase_14 AC 673 ms
95,348 KB
testcase_15 AC 606 ms
92,736 KB
testcase_16 AC 594 ms
90,784 KB
testcase_17 AC 611 ms
93,076 KB
testcase_18 AC 450 ms
86,540 KB
testcase_19 AC 532 ms
88,340 KB
testcase_20 AC 540 ms
87,588 KB
testcase_21 AC 569 ms
90,832 KB
testcase_22 AC 641 ms
93,308 KB
testcase_23 AC 110 ms
78,112 KB
testcase_24 AC 401 ms
86,420 KB
testcase_25 AC 222 ms
82,236 KB
testcase_26 AC 387 ms
85,356 KB
testcase_27 AC 140 ms
79,356 KB
testcase_28 AC 78 ms
75,900 KB
testcase_29 AC 247 ms
81,752 KB
testcase_30 AC 102 ms
77,840 KB
testcase_31 AC 144 ms
79,272 KB
testcase_32 AC 95 ms
77,500 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