結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
square1001
|
| 提出日時 | 2019-07-26 21:23:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 230 ms / 3,153 ms |
| コード長 | 580 bytes |
| コンパイル時間 | 512 ms |
| コンパイル使用メモリ | 70,164 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-02 06:34:14 |
| 合計ジャッジ時間 | 4,228 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
cin.tie(0);
ios_base::sync_with_stdio(false);
string s;
cin >> s;
long long sum = 0;
for (int i = 1; i <= 26; ++i) {
vector<int> c(26);
int cur = 0, ptr = 0;
for (int j = 0; j < s.size(); ++j) {
while (ptr != s.size() && cur < i) {
if (c[s[ptr++] - 'a']++ == 0) ++cur;
}
if (cur == i) sum += s.size() - ptr + 1;
if (--c[s[j] - 'a'] == 0) --cur;
}
}
cout.precision(15);
cout << fixed << sum / double(1LL * s.size() * (s.size() + 1) / 2) << endl;
return 0;
}
square1001