結果

問題 No.852 連続部分文字列
ユーザー hiro71687khiro71687k
提出日時 2023-08-02 05:29:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,009 ms / 3,153 ms
コード長 854 bytes
コンパイル時間 4,609 ms
コンパイル使用メモリ 259,972 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 05:28:32
合計ジャッジ時間 27,541 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 36 ms
6,944 KB
testcase_14 AC 17 ms
6,944 KB
testcase_15 AC 60 ms
6,940 KB
testcase_16 AC 35 ms
6,940 KB
testcase_17 AC 49 ms
6,940 KB
testcase_18 AC 62 ms
6,940 KB
testcase_19 AC 5 ms
6,944 KB
testcase_20 AC 28 ms
6,940 KB
testcase_21 AC 64 ms
6,940 KB
testcase_22 AC 21 ms
6,940 KB
testcase_23 AC 44 ms
6,944 KB
testcase_24 AC 25 ms
6,944 KB
testcase_25 AC 43 ms
6,944 KB
testcase_26 AC 63 ms
6,940 KB
testcase_27 AC 37 ms
6,944 KB
testcase_28 AC 50 ms
6,940 KB
testcase_29 AC 65 ms
6,944 KB
testcase_30 AC 13 ms
6,944 KB
testcase_31 AC 67 ms
6,944 KB
testcase_32 AC 70 ms
6,940 KB
testcase_33 AC 2,001 ms
6,940 KB
testcase_34 AC 1,935 ms
6,940 KB
testcase_35 AC 2,009 ms
6,944 KB
testcase_36 AC 1,958 ms
6,944 KB
testcase_37 AC 1,962 ms
6,940 KB
testcase_38 AC 1,961 ms
6,940 KB
testcase_39 AC 1,991 ms
6,944 KB
testcase_40 AC 1,948 ms
6,944 KB
testcase_41 AC 1,975 ms
6,940 KB
testcase_42 AC 1,380 ms
6,944 KB
testcase_43 AC 955 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=100990999999999909;
int main(){
    string s;
    cin >> s;
    vector<ll>memo(100,-1);
    ll ans=0;
    for (ll i = 0; i < s.size(); i++)
    {
        map<ll,ll>mm;
        ll now=0;
        memo[s[i]-'a']=max(memo[s[i]-'a'],i);
        for (char c = 'a'; c <='z'; c++)
        {
            if (memo[c-'a']!=-1)
            {
                now++;
                mm[memo[c-'a']]++;
            }
        }
        ll pre=-1;
        for(auto v:mm){
            ans+=now*(v.first-pre);
            pre=v.first;
            now--;
        }

    }
    ll n=s.size();
    ll x=(n*(n+1))/2;
    ld y=ans;
    ld z=x;
    cout << setprecision(100) << y/z << endl; 
}
0