結果

問題 No.852 連続部分文字列
ユーザー Mayimg
提出日時 2019-07-27 01:06:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 432 bytes
コンパイル時間 2,092 ms
コンパイル使用メモリ 193,852 KB
最終ジャッジ日時 2025-01-07 09:00:11
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  vector<int> pre(26, -1);
  long long tot = 0;
  int n = (int) s.size();
  for (int i = 0; i < n; i++) {
    tot += 1LL * (i - pre[s[i] - 'a']) * (n - i);
    pre[s[i] - 'a'] = i;
  }
  cout << setprecision(20) << fixed << 1.0 * tot / (n * (n + 1) / 2) << endl;
  return 0;
}
0