結果

問題 No.1845 Long Substrings
ユーザー 👑 potato167potato167
提出日時 2021-12-19 00:25:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,588 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 208,308 KB
実行使用メモリ 15,148 KB
最終ジャッジ日時 2023-10-14 23:14:03
合計ジャッジ時間 7,029 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 41 ms
9,252 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 74 ms
15,148 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 44 ms
9,808 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 67 ms
13,840 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 51 ms
10,464 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 48 ms
12,136 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 3 ms
4,348 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 44 ms
10,536 KB
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 34 ms
8,764 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 49 ms
12,540 KB
testcase_29 RE -
testcase_30 AC 2 ms
4,352 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 51 ms
12,352 KB
testcase_33 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll ILL=1167167167167167167;
const int INF=2100000000;
ll mod=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
void yneos(bool a){if(a) cout<<"Yes\n"; else cout<<"No\n";}



//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	ll sum=0;
	vector<ll> p(N);
	rep(i,N){
		cin>>p[i];
		sum+=p[i];
	}
	string T;
	cin>>T;
	assert(sum<=1e7);
	string S;
	rep(i,N){
		rep(j,p[i]) S+=T[i];
	}
	N=S.size();
	int M=26;
	vector<queue<int>> q(M);
	rep(i,N){
		q[(S[i]-'a')].push(i);
	}
	rep(i,M) q[i].push(N+1);
	vector<ll> dp(N+2);
	rep(i,M){
		dp[q[i].front()]=1;
	}
	ll ans=0;
	rep(i,N){
		dp[i]%=mod;
		ans+=dp[i];
		ans%=mod;
		rep(j,M){
			if(q[j].front()==i) q[j].pop();
			dp[q[j].front()]+=dp[i];
		}
	}
	cout<<ans<<"\n";
}


0