結果

問題 No.1996 <><
ユーザー shobonvipshobonvip
提出日時 2022-07-01 22:38:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 1,076 bytes
コンパイル時間 4,284 ms
コンパイル使用メモリ 272,852 KB
実行使用メモリ 12,172 KB
最終ジャッジ日時 2023-08-17 10:10:44
合計ジャッジ時間 6,810 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 36 ms
7,540 KB
testcase_12 AC 70 ms
12,172 KB
testcase_13 AC 86 ms
12,148 KB
testcase_14 AC 82 ms
11,832 KB
testcase_15 AC 75 ms
10,512 KB
testcase_16 AC 62 ms
9,792 KB
testcase_17 AC 71 ms
10,512 KB
testcase_18 AC 40 ms
7,568 KB
testcase_19 AC 49 ms
8,616 KB
testcase_20 AC 48 ms
8,136 KB
testcase_21 AC 62 ms
9,628 KB
testcase_22 AC 73 ms
10,736 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 40 ms
7,512 KB
testcase_25 AC 19 ms
5,708 KB
testcase_26 AC 35 ms
6,568 KB
testcase_27 AC 8 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 18 ms
5,456 KB
testcase_30 AC 3 ms
4,376 KB
testcase_31 AC 7 ms
4,524 KB
testcase_32 AC 2 ms
4,380 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