結果

問題 No.1996 <><
ユーザー trineutrontrineutron
提出日時 2022-07-01 22:10:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,263 bytes
コンパイル時間 2,250 ms
コンパイル使用メモリ 216,060 KB
実行使用メモリ 20,844 KB
最終ジャッジ日時 2023-08-17 09:41:41
合計ジャッジ時間 5,069 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 60 ms
12,024 KB
testcase_12 AC 191 ms
20,732 KB
testcase_13 AC 181 ms
20,844 KB
testcase_14 AC 171 ms
20,256 KB
testcase_15 AC 139 ms
17,880 KB
testcase_16 AC 111 ms
16,048 KB
testcase_17 AC 132 ms
17,964 KB
testcase_18 AC 59 ms
11,864 KB
testcase_19 AC 71 ms
13,408 KB
testcase_20 AC 77 ms
12,920 KB
testcase_21 AC 119 ms
16,088 KB
testcase_22 AC 141 ms
18,404 KB
testcase_23 AC 5 ms
4,504 KB
testcase_24 AC 62 ms
11,760 KB
testcase_25 AC 28 ms
7,772 KB
testcase_26 AC 49 ms
9,908 KB
testcase_27 AC 10 ms
4,912 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 26 ms
7,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 10 ms
5,004 KB
testcase_32 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#include <atcoder/fenwicktree>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint1000000007;

void compress(vector<int> &a) {
    auto sorted{a};
    sort(sorted.begin(), sorted.end());
    sorted.erase(unique(sorted.begin(), sorted.end()), sorted.end());
    for (auto &&x : a) {
        x = lower_bound(sorted.begin(), sorted.end(), x) - sorted.begin();
    }
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    compress(a);
    string s;
    cin >> s;

    vector dp(n + 1, vector<mint>(k + 1));
    vector t(k + 1, fenwick_tree<mint>(n));
    for (int i = 0; i < n; i++) {
        dp.at(i + 1).at(0) = 1;
        t.at(0).add(a.at(i), 1);
        for (int j = 0; j <= k; j++) {
            dp.at(i + 1).at(j) += dp.at(i).at(j);
            if (j == k) continue;
            mint d;
            if (s.at(j) == '<') {
                d = t.at(j).sum(0, a.at(i));
            } else {
                d = t.at(j).sum(a.at(i) + 1, n);
            }
            dp.at(i + 1).at(j + 1) += d;
            t.at(j + 1).add(a.at(i), d);
        }
    }

    cout << dp.back().back().val() << endl;
    return 0;
}
0