結果

問題 No.852 連続部分文字列
ユーザー leaf_1415leaf_1415
提出日時 2019-07-26 21:40:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 484 ms
コンパイル使用メモリ 64,600 KB
実行使用メモリ 15,888 KB
最終ジャッジ日時 2023-09-15 00:50:35
合計ジャッジ時間 2,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#define llint long long

using namespace std;

string s;
vector<llint> vec[26];

int main(void)
{
	cin >> s;
	int n = s.size();
	s = "#" + s;
	for(int i = 0; i < 26; i++) vec[i].push_back(0);
	for(int i = 1; i <= n; i++){
		vec[s[i]-'a'].push_back(i);
	}
	for(int i = 0; i < 26; i++) vec[i].push_back(n+1);
	
	llint ans = 0;
	for(int i = 0; i < 26; i++){
		ans += n*(n+1)/2;
		for(int j = 1; j < vec[i].size(); j++){
			llint len = vec[i][j]-vec[i][j-1]-1;
			ans -= len*(len+1)/2;
		}
	}
	printf("%.11f\n", (double)ans / (n*(n+1)/2));
	
	return 0;
}
0