結果
問題 | No.1845 Long Substrings |
ユーザー |
![]() |
提出日時 | 2022-02-19 05:18:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 37 ms / 2,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 4,996 ms |
コンパイル使用メモリ | 255,844 KB |
最終ジャッジ日時 | 2025-01-28 00:58:38 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++)#define ALL(v) v.begin(),v.end()typedef long long ll;#include <atcoder/all>#include <bits/stdc++.h>using namespace std;using namespace atcoder;using mint=modint1000000007;int main(){ios::sync_with_stdio(false);std::cin.tie(nullptr);int n;cin>>n;vector<ll> A(n);rep(i,n) cin>>A[i];string s;cin>>s;mint ans=1;map<char,mint> dp;rep(i,n){mint tmp=ans;ans=(A[i]+1)*ans-A[i]*dp[s[i]];dp[s[i]]=A[i]*tmp-(A[i]-1)*dp[s[i]];}ans-=1;cout<<ans.val()<<endl;return 0;}