結果
| 問題 |
No.1996 <><
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2022-07-01 21:36:41 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 384 ms / 2,000 ms |
| コード長 | 861 bytes |
| コンパイル時間 | 5,195 ms |
| コンパイル使用メモリ | 258,100 KB |
| 最終ジャッジ日時 | 2025-01-30 02:31:16 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
int main(){
int N,K;
cin>>N>>K;
vector<int> a(N);
rep(i,N){
cin>>a[i];
}
vector<int> t = a;
sort(t.begin(),t.end());
t.erase(unique(t.begin(),t.end()),t.end());
rep(i,N){
a[i] = distance(t.begin(),lower_bound(t.begin(),t.end(),a[i]));
}
string S;
cin>>S;
vector<fenwick_tree<mint>> F(K+2,fenwick_tree<mint>(t.size()));
rep(i,N){
for(int j=1;j<=K+1;j++){
if(j==1){
F[j].add(a[i],1);
}
else{
if(S[j-2]=='>'){
F[j].add(a[i],F[j-1].sum(a[i]+1,t.size()));
}
else{
F[j].add(a[i],F[j-1].sum(0,a[i]));
}
}
}
}
cout<<F[K+1].sum(0,t.size()).val()<<endl;
return 0;
}
沙耶花