結果

問題 No.962 LCPs
ユーザー ngtkanangtkana
提出日時 2020-04-11 14:52:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 1,096 bytes
コンパイル時間 4,465 ms
コンパイル使用メモリ 209,772 KB
実行使用メモリ 20,400 KB
最終ジャッジ日時 2023-10-19 05:42:38
合計ジャッジ時間 8,188 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 32 ms
20,400 KB
testcase_18 AC 19 ms
11,952 KB
testcase_19 AC 20 ms
11,952 KB
testcase_20 AC 15 ms
9,048 KB
testcase_21 AC 14 ms
9,048 KB
testcase_22 AC 12 ms
8,256 KB
testcase_23 AC 12 ms
8,256 KB
testcase_24 AC 10 ms
7,200 KB
testcase_25 AC 10 ms
7,200 KB
testcase_26 AC 10 ms
7,200 KB
testcase_27 AC 13 ms
8,520 KB
testcase_28 AC 10 ms
7,200 KB
testcase_29 AC 9 ms
6,672 KB
testcase_30 AC 12 ms
8,256 KB
testcase_31 AC 14 ms
9,840 KB
testcase_32 AC 9 ms
6,672 KB
testcase_33 AC 19 ms
11,688 KB
testcase_34 AC 9 ms
7,200 KB
testcase_35 AC 9 ms
7,200 KB
testcase_36 AC 12 ms
7,992 KB
testcase_37 AC 9 ms
6,408 KB
testcase_38 AC 9 ms
6,408 KB
testcase_39 AC 9 ms
6,408 KB
testcase_40 AC 9 ms
6,408 KB
testcase_41 AC 9 ms
6,408 KB
testcase_42 AC 9 ms
6,408 KB
testcase_43 AC 9 ms
6,408 KB
testcase_44 AC 9 ms
6,408 KB
testcase_45 AC 9 ms
6,408 KB
testcase_46 AC 8 ms
6,408 KB
testcase_47 AC 4 ms
4,824 KB
testcase_48 AC 3 ms
4,560 KB
testcase_49 AC 4 ms
4,824 KB
testcase_50 AC 4 ms
4,824 KB
testcase_51 AC 4 ms
4,696 KB
testcase_52 AC 4 ms
4,348 KB
testcase_53 AC 4 ms
4,824 KB
testcase_54 AC 4 ms
4,560 KB
testcase_55 AC 3 ms
4,348 KB
testcase_56 AC 4 ms
5,088 KB
testcase_57 AC 5 ms
4,828 KB
testcase_58 AC 5 ms
4,828 KB
testcase_59 AC 5 ms
4,828 KB
testcase_60 AC 6 ms
5,256 KB
testcase_61 AC 6 ms
5,256 KB
testcase_62 AC 6 ms
5,256 KB
testcase_63 AC 23 ms
14,464 KB
testcase_64 AC 4 ms
5,220 KB
testcase_65 AC 22 ms
14,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
void cmn(lint&x,lint y){if(x>y)x=y;}
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n;std::cin>>n;
    std::vector<std::string>s(n);
    for(auto&&t:s)std::cin>>t;
    std::vector<std::vector<lint>>a(n);
    for(lint i=n-1;i>=0;i--){
        auto&&now=a.at(i);
        a.at(i).resize(s.at(i).length(),1);
        if(i==n-1)continue;
        auto&next=a.at(i+1);
        for(lint j=0;j<(lint)std::min(now.size(),next.size());j++){
            if(s.at(i).at(j)!=s.at(i+1).at(j))continue;
            now.at(j)=next.at(j)+1;
            if(j)cmn(now.at(j),now.at(j-1));
        }
    }
    auto comb=[&](lint n){return n*(n+1)*(n+2)/6;};
    lint ans=0;
    for(lint i=0;i<n;i++){
        for(lint j=0;j<(lint)a.at(i).size();j++){
            if(i&&j<(lint)a.at(i-1).size()&&1<a.at(i-1).at(j))continue;
            ans+=comb(a.at(i).at(j));
        }
    }
    std::cout<<ans<<'\n';
}
0