結果

問題 No.1996 <><
ユーザー MasKoaTSMasKoaTS
提出日時 2022-05-04 19:56:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 3,956 ms
コンパイル使用メモリ 268,388 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-04 14:45:25
合計ジャッジ時間 5,201 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 15 ms
5,376 KB
testcase_12 AC 28 ms
5,376 KB
testcase_13 AC 45 ms
5,376 KB
testcase_14 AC 44 ms
5,376 KB
testcase_15 AC 38 ms
5,376 KB
testcase_16 AC 33 ms
5,376 KB
testcase_17 AC 38 ms
5,376 KB
testcase_18 AC 22 ms
5,376 KB
testcase_19 AC 27 ms
5,376 KB
testcase_20 AC 26 ms
5,376 KB
testcase_21 AC 33 ms
5,376 KB
testcase_22 AC 40 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 23 ms
5,376 KB
testcase_25 AC 10 ms
5,376 KB
testcase_26 AC 19 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 11 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 4 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, l, n) for (int i = (l); i < (n); i++)
#define all(x) x.begin(), x.end()
#define lb(a, x) lower_bound(all(a), x) - a.begin()
using namespace std;
using namespace atcoder;
using ll = long long;
template <class T>	using V = vector<T>;
template <class T>	using BIT = fenwick_tree<T>;
const ll mod = 1000000007;


int main(void) {
	int N, K;	cin >> N >> K;
	V<ll> a(N), b(N);
	rep(i, 0, N) {
		cin >> a[i];
	}
	string s;	cin >> s;

	V<ll> st = a;	sort(all(st));
	st.erase(unique(all(st)), st.end());
	rep(i, 0, a.size()) {
		a[i] = lb(st, a[i]);
		b[i] = st.size() - 1 - a[i];
	}

	V<ll> dp(N, 1);
	rep(i, 0, K) {
		V<ll> ndp(N);
		BIT<ll> bt(N);
		if (s[i] == '<') {
			rep(j, 0, N) {
				ll k = a[j];
				bt.add(k, dp[j]);
				ndp[j] = bt.sum(0, (int)k) % mod;
			}
		}
		else {
			rep(j, 0, N) {
				ll k = b[j];
				bt.add(k, dp[j]);
				ndp[j] = bt.sum(0, (int)k) % mod;
			}
		}
		rep(j, 0, N) {
			dp[j] = ndp[j];
		}
	}

	ll ans = 0;
	for (ll t : dp) {
		ans += t;
		ans %= mod;
	}
	cout << ans << endl;

	return 0;
}
0