結果
問題 |
No.1996 <><
|
ユーザー |
![]() |
提出日時 | 2022-05-14 15:09:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 945 bytes |
コンパイル時間 | 4,392 ms |
コンパイル使用メモリ | 254,064 KB |
最終ジャッジ日時 | 2025-01-29 08:00:49 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 TLE * 11 |
ソースコード
//TLE(?) #include <bits/stdc++.h> #include <atcoder/all> #define rep(i, l, n) for (int i = (l); i < (n); i++) using namespace std; using namespace atcoder; using ll = long long; template <class T> using V = vector<T>; const ll mod = 1000000007; int main(void) { int N, K; cin >> N >> K; V<int> a(N); rep(i, 0, N) { cin >> a[i]; } string s; cin >> s; V<V<int> > up(N, V<int>({})); V<V<int> > down(N, V<int>({})); rep(i, 0, N) { rep(j, 0, i) { if (a[j] > a[i]) { up[i].push_back(j); } if (a[j] < a[i]) { down[i].push_back(j); } } } V<ll> dp(N, 1); rep(i, 0, K) { V<ll> ndp(N); rep(j, 0, N) { if (s[i] == '<') { for (int k : down[j]) { ndp[j] += dp[k]; ndp[j] %= mod; } } else { for (int k : up[j]) { ndp[j] += dp[k]; ndp[j] %= mod; } } } dp = ndp; } ll ans = 0; for (ll t : dp) { ans += t; ans %= mod; } cout << ans << endl; return 0; }