結果
| 問題 |
No.1996 <><
|
| コンテスト | |
| ユーザー |
MasKoaTS
|
| 提出日時 | 2022-05-04 19:53:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 1,177 bytes |
| コンパイル時間 | 4,386 ms |
| コンパイル使用メモリ | 257,896 KB |
| 最終ジャッジ日時 | 2025-01-29 02:19:43 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
// WA(?)
#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;
using str = string;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<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];
}
str 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);
ndp[j] %= mod;
}
}
else {
rep(j, 0, N) {
ll k = b[j];
bt.add(k, dp[j]);
ndp[j] = bt.sum(0, (int)k);
ndp[j] %= 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;
}
MasKoaTS