結果
問題 | No.1845 Long Substrings |
ユーザー |
![]() |
提出日時 | 2023-08-16 20:57:20 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 716 bytes |
コンパイル時間 | 5,602 ms |
コンパイル使用メモリ | 311,212 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 11:11:48 |
合計ジャッジ時間 | 7,891 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 21 |
ソースコード
#include<bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using mint=modint1000000007;using ll=long long;using pp=pair<int,int>;#define sr string#define vc vector#define fi first#define se second#define rep(i,n) for(int i=0;i<(int)n;i++)#define pb push_back#define all(v) v.begin(),v.end()#define pque priority_queue#define bpc(a) __builtin_popcount(a)int main(){int n;cin>>n;vc<ll>v(n); rep(i,n)cin>>v[i];sr s;cin>>s;vc<mint>dp(n+1,0); dp[0]=1;vc<int>last(26,-1);rep(i,n){auto&x=dp[i+1];x=dp[i]*(v[i]+1);int t=last[s[i]-'a'];if(t!=-1)x-=(dp[t]-dp[t-1])*(v[i]);last[s[i]-'a']=i+1;}mint ans=dp[n]-1;cout<<ans.val();}