結果

問題 No.1845 Long Substrings
ユーザー umezo
提出日時 2022-02-19 05:06:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 4,857 ms
コンパイル使用メモリ 261,832 KB
最終ジャッジ日時 2025-01-28 00:58:16
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
  map<ll,mint> dp1;
  rep(i,n){
    mint tmp=ans;
    ans+=A[i]*(ans-dp1[s[i]]*dp[s[i]]);
    dp[s[i]]=tmp;
    dp1[s[i]]=A[i];
  }
  ans-=1;
  cout<<ans.val()<<endl;
  
  return 0;
}
0