結果

問題 No.1996 <><
ユーザー ShirotsumeShirotsume
提出日時 2022-05-05 03:09:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 958 bytes
コンパイル時間 363 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 98,588 KB
最終ジャッジ日時 2023-08-17 07:58:25
合計ジャッジ時間 5,025 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
75,704 KB
testcase_01 AC 74 ms
71,420 KB
testcase_02 AC 74 ms
71,416 KB
testcase_03 AC 80 ms
76,420 KB
testcase_04 AC 73 ms
71,648 KB
testcase_05 AC 74 ms
71,336 KB
testcase_06 AC 73 ms
71,492 KB
testcase_07 AC 73 ms
71,528 KB
testcase_08 AC 86 ms
76,620 KB
testcase_09 AC 80 ms
76,400 KB
testcase_10 AC 85 ms
76,556 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
INF = 2 ** 63 - 1
mod = 10 ** 9 + 7

n, k = mi()
a = li()
s = input()

upgraph = [[] for _ in range(n)]
downgraph = [[] for _ in range(n)]

for i in range(n):
    for j in range(i + 1, n):
        if a[i] < a[j]:
            upgraph[i].append(j)
        elif a[i] > a[j]:
            downgraph[i].append(j)
dp = [[0] * (k + 1) for _ in range(n + 1)]
for i in range(n):
    dp[i][0] = 1
for i in range(n):
    for j in range(max(0, k - (n - i)), min(i + 1, k)):
        if s[j] == '<':
            for to in upgraph[i]:
                dp[to][j + 1] += dp[i][j]
                dp[to][j + 1] %= mod
        elif s[j] == '>':
            for to in downgraph[i]:
                dp[to][j + 1] += dp[i][j]
                dp[to][j + 1] %= mod

ans = 0
for i in range(n):
    ans += dp[i][k]
    ans %= mod
print(ans)
0