結果

問題 No.852 連続部分文字列
ユーザー sinsincoscossinsincoscos
提出日時 2019-07-26 21:40:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 772 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 78,124 KB
実行使用メモリ 493,176 KB
最終ジャッジ日時 2023-09-15 00:50:06
合計ジャッジ時間 9,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 101 ms
11,012 KB
testcase_14 AC 44 ms
6,724 KB
testcase_15 AC 163 ms
16,580 KB
testcase_16 AC 99 ms
11,032 KB
testcase_17 AC 138 ms
14,404 KB
testcase_18 AC 174 ms
17,352 KB
testcase_19 AC 13 ms
4,572 KB
testcase_20 AC 78 ms
9,660 KB
testcase_21 AC 182 ms
17,868 KB
testcase_22 AC 57 ms
7,720 KB
testcase_23 AC 121 ms
13,148 KB
testcase_24 AC 67 ms
8,648 KB
testcase_25 AC 118 ms
12,864 KB
testcase_26 AC 174 ms
17,292 KB
testcase_27 AC 103 ms
11,780 KB
testcase_28 AC 136 ms
14,464 KB
testcase_29 AC 178 ms
17,884 KB
testcase_30 AC 33 ms
6,112 KB
testcase_31 AC 189 ms
18,428 KB
testcase_32 AC 198 ms
18,884 KB
testcase_33 MLE -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;
    ll N = S.size();
    vector<vector<ll>> ne(N+2,vector<ll>(26,N));
    vector<vector<ll>> pre(N+2,vector<ll>(26,0));
    for(int i=1;i<=N;i++){
        for(int j=0;j<26;j++) pre[i][j] = pre[i-1][j];
        pre[i][S[i-1]-'a'] = i;
    }
    for(int i=N;i>=1;i--){
        for(int j=0;j<26;j++) ne[i][j] = ne[i+1][j];
        ne[i][S[i-1]-'a'] = i;
    }
    ll ans = 0;
    for(ll i=1;i<=N;i++){
        ll l = i-pre[i-1][S[i-1]-'a'],r = N+1-i;
        cerr << l << " " << r << endl;
        ans += l*r;
    }
//    cout << ans << endl;
    cout << fixed;
    cout << setprecision(10) << (long double) ans/(N*(N+1)/2) << endl;
}
0