結果

問題 No.1996 <><
ユーザー Kiri8128Kiri8128
提出日時 2022-07-01 22:43:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,632 ms / 2,000 ms
コード長 1,560 bytes
コンパイル時間 433 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 97,168 KB
最終ジャッジ日時 2023-08-17 10:18:19
合計ジャッジ時間 21,275 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,080 KB
testcase_01 AC 70 ms
71,048 KB
testcase_02 AC 69 ms
71,144 KB
testcase_03 AC 77 ms
75,832 KB
testcase_04 AC 68 ms
71,448 KB
testcase_05 AC 70 ms
71,172 KB
testcase_06 AC 73 ms
71,076 KB
testcase_07 AC 74 ms
71,528 KB
testcase_08 AC 98 ms
77,312 KB
testcase_09 AC 80 ms
75,888 KB
testcase_10 AC 94 ms
76,544 KB
testcase_11 AC 796 ms
87,296 KB
testcase_12 AC 1,485 ms
96,728 KB
testcase_13 AC 1,632 ms
96,872 KB
testcase_14 AC 1,574 ms
97,168 KB
testcase_15 AC 1,400 ms
93,504 KB
testcase_16 AC 1,272 ms
91,964 KB
testcase_17 AC 1,475 ms
93,856 KB
testcase_18 AC 877 ms
86,860 KB
testcase_19 AC 991 ms
88,724 KB
testcase_20 AC 813 ms
88,640 KB
testcase_21 AC 1,111 ms
91,548 KB
testcase_22 AC 1,340 ms
93,860 KB
testcase_23 AC 139 ms
78,456 KB
testcase_24 AC 803 ms
86,592 KB
testcase_25 AC 385 ms
82,664 KB
testcase_26 AC 632 ms
85,352 KB
testcase_27 AC 192 ms
79,412 KB
testcase_28 AC 88 ms
76,332 KB
testcase_29 AC 371 ms
82,188 KB
testcase_30 AC 118 ms
77,540 KB
testcase_31 AC 189 ms
79,748 KB
testcase_32 AC 114 ms
77,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class DualBIT():
    def __init__(self, init):
        if type(init) == int:
            self.n = init + 1
            self.X = [0] * self.n
        else:
            self.n = len(init) + 1
            self.X = [0] + init
            for i in range(1, self.n):
                if i + (i & -i) < self.n:
                    self.X[i + (i & -i)] += self.X[i]
    def _add(self, i, x=1):
        i += 1
        while i < self.n:
            self.X[i] = (self.X[i] + x) % P
            i += i & (-i)

    def add_range(self, l, r, x=1):
        self._add(l, x)
        self._add(r, -x)
    
    def getvalue(self, i):
        ret = 0
        i += 1
        while i != 0:
            ret = (ret + self.X[i]) % P
            i -= i & (-i)
        return ret
    
    def disp(self):
        return [self.getvalue(i) for i in range(N)]

P = 10 ** 9 + 7
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
S = [1 if s == "<" else -1 for s in input()]
SA = sorted(set(A))
IA = {a: i for i, a in enumerate(SA)}
AA = [IA[a] for a in A]
M = len(SA)
bits = [DualBIT(N) for _ in range(K + 1)]
bits[0].add_range(0, M, 1)
ans = 0
for i in range(N):
    a = AA[i]
    for j in range(1, K + 1)[::-1]:
        c = bits[j].getvalue(a)
        if j == K:
            ans += c
            continue
        s = S[j]
        if s > 0:
            bits[j+1].add_range(a + 1, M, c)
        else:
            bits[j+1].add_range(0, a, c)
    
    s = S[0]
    if s > 0:
        bits[1].add_range(a + 1, M, 1)
    else:
        bits[1].add_range(0, a, 1)
print(ans % P)
0