結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2019-07-26 21:52:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 3,153 ms |
| コード長 | 542 bytes |
| コンパイル時間 | 557 ms |
| コンパイル使用メモリ | 73,928 KB |
| 実行使用メモリ | 5,428 KB |
| 最終ジャッジ日時 | 2024-07-02 07:02:06 |
| 合計ジャッジ時間 | 2,196 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main() {
string s;
cin >> s;
int n = (int)s.size();
int p[256];
for (int j = 0; j < 256; j++) {
p[j] = -1;
}
double r = 0, t = 0;
for (int i = 0; i < n; i++) {
int d = i - p[s[i]];
p[s[i]] = i;
t = t + d;
r += t;
}
printf("%.8f\n", r / ((double)n * (n + 1) / 2));
return 0;
}
merom686