結果

問題 No.1996 <><
ユーザー shobonvipshobonvip
提出日時 2022-07-01 22:38:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 4,276 ms
コンパイル使用メモリ 275,740 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-05-04 16:59:33
合計ジャッジ時間 6,108 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 36 ms
7,680 KB
testcase_12 AC 67 ms
12,288 KB
testcase_13 AC 79 ms
12,288 KB
testcase_14 AC 76 ms
12,032 KB
testcase_15 AC 67 ms
10,624 KB
testcase_16 AC 55 ms
9,856 KB
testcase_17 AC 66 ms
10,880 KB
testcase_18 AC 37 ms
7,552 KB
testcase_19 AC 46 ms
8,448 KB
testcase_20 AC 46 ms
8,192 KB
testcase_21 AC 59 ms
9,856 KB
testcase_22 AC 67 ms
11,008 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 37 ms
7,680 KB
testcase_25 AC 18 ms
5,888 KB
testcase_26 AC 32 ms
6,948 KB
testcase_27 AC 8 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 17 ms
5,504 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 8 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace atcoder;
typedef long long ll;
const ll INF = 1e18;
typedef modint1000000007 mint;
//cout << fixed << setprecision(12);

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}

	vector<int> b = a;
	sort(b.begin(), b.end());
	b.erase(unique(b.begin(), b.end()), b.end());
	unordered_map<int,int> a_c;
	for(int i=0; i<b.size(); i++){
		a_c[b[i]] = i;
	}

	vector<int> a_z(n);
	rep(i,n){
		a_z[i] = a_c[a[i]];
	}
	int azs = a_z.size();

	vector<char> s(k);
	rep(i,k){
		cin >> s[i];
	}

	vector<vector<mint>> dp(k+1,vector<mint>(n));
	rep(i,n){
		dp[0][i] = 1;
	}

	rep(num,k){
		fenwick_tree<mint> bit(azs);
		if(s[num] == '<'){
			rep(i,n){
				dp[num+1][i] += bit.sum(0, a_z[i]);
				bit.add(a_z[i], dp[num][i]);
			}
		}else{
			rep(i,n){
				dp[num+1][i] += bit.sum(a_z[i]+1, azs);
				bit.add(a_z[i], dp[num][i]);
			}
		}
	}

	mint ans = 0;
	rep(i,n){
		ans += dp[k][i];
	}
	cout << ans.val() << endl;

}
0