結果

問題 No.1996 <><
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-05-14 01:43:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 1,686 bytes
コンパイル時間 4,641 ms
コンパイル使用メモリ 270,832 KB
実行使用メモリ 12,120 KB
最終ジャッジ日時 2023-08-19 20:45:27
合計ジャッジ時間 7,933 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 46 ms
7,556 KB
testcase_12 AC 177 ms
12,088 KB
testcase_13 AC 258 ms
12,120 KB
testcase_14 AC 243 ms
11,800 KB
testcase_15 AC 181 ms
10,572 KB
testcase_16 AC 144 ms
9,396 KB
testcase_17 AC 178 ms
10,480 KB
testcase_18 AC 54 ms
7,384 KB
testcase_19 AC 83 ms
8,104 KB
testcase_20 AC 69 ms
7,840 KB
testcase_21 AC 127 ms
9,744 KB
testcase_22 AC 158 ms
10,772 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 49 ms
7,288 KB
testcase_25 AC 22 ms
5,604 KB
testcase_26 AC 39 ms
6,520 KB
testcase_27 AC 8 ms
4,380 KB
testcase_28 AC 2 ms
4,384 KB
testcase_29 AC 20 ms
5,484 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
#include<bits/stdc++.h>
#include<atcoder/all>

using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint1000000007;

template<class T> struct BIT {
    vector<T> bit;
    long long N;

    BIT (long long n){
        N = n;
        bit.resize(N);
    }

    void add(long long loc, T val){
        loc++;
        while(loc <= N){
            bit[loc-1] += val;
            loc += loc & -loc;
        }
    }

    T sum(long long l, long long r){
        T res = _sum(r) - _sum(l-1);
        return res;
    }

    T _sum(long long r){
        r++;
        T res = 0;
        while(r > 0){
            res += bit[r-1];
            r -= r & -r;
        }
        return res;
    }
};

template <typename T>
void compress(vector<T> &A){

    map<T, T> comp;
    int N = A.size(), i=0;
    for (int i=0; i<N; i++) comp[A[i]];

    for (auto &e : comp){
        e.second = i;
        i++;
    }

    for (int i=0; i<N; i++) A[i] = comp[A[i]];
}

int main(){

    ll N, K;
    string S;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i=0; i<N; i++) cin >> A[i];
    cin >> S;
    compress(A);
    vector<BIT<mint>> dp(K+1, BIT<mint>(N));

    for (int i=0; i<N; i++){
        for (int j=1; j<=K; j++){
            if (S[j-1] == '<') dp[j].add(A[i], dp[j-1].sum(0, A[i]-1));
            else dp[j].add(A[i], dp[j-1].sum(A[i]+1, N-1));
        }
        dp[0].add(A[i], 1);
    }

    cout << dp[K].sum(0, N-1).val() << endl;

    return 0;
}
0