結果

問題 No.1845 Long Substrings
ユーザー 👑 tatyamtatyam
提出日時 2021-12-22 11:24:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 683 bytes
コンパイル時間 3,836 ms
コンパイル使用メモリ 267,884 KB
実行使用メモリ 20,516 KB
最終ジャッジ日時 2023-10-14 23:13:34
合計ジャッジ時間 9,216 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 RE -
testcase_16 WA -
testcase_17 RE -
testcase_18 RE -
testcase_19 WA -
testcase_20 RE -
testcase_21 RE -
testcase_22 WA -
testcase_23 RE -
testcase_24 RE -
testcase_25 WA -
testcase_26 RE -
testcase_27 RE -
testcase_28 WA -
testcase_29 RE -
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 2 ms
4,352 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/string>
#include <atcoder/modint>
using namespace std;
using Modint = atcoder::modint1000000007;


Modint solve(string s){
    auto sa = atcoder::suffix_array(s);
    Modint ans = s.size() * (s.size() + 1) / 2;
    for(auto i : atcoder::lcp_array(s, sa)) ans -= i;
    return ans;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int& a : A) cin >> a;
    if(accumulate(A.begin(), A.end(), 0LL) >= 2e7) abort();
    string S;
    for(int i = 0; i < N; i++){
        char c;
        cin >> c;
        S += string(A[i], c);
    }
    cout << solve(S).val() << endl;
}
0