結果
問題 | No.1845 Long Substrings |
ユーザー |
|
提出日時 | 2022-03-14 20:48:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 525 bytes |
コンパイル時間 | 2,902 ms |
コンパイル使用メモリ | 251,168 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 08:57:38 |
合計ジャッジ時間 | 6,300 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/modint>using namespace std;using Mint = atcoder::modint1000000007;int main(){int N;cin >> N;vector<int> A(N);for (int &a : A)cin >> a;string s;cin >> s;vector<Mint> lst(26);Mint pre = 1;for (int i = 0; i < N; i++){Mint pp = pre;Mint ref = lst[s[i] - 'a'];pre = (A[i] + 1) * pp - A[i] * ref;lst[s[i] - 'a'] = A[i] * pp - (A[i] - 1) * ref;}cout << (pre - 1).val() << endl;}