結果
| 問題 | 
                            No.852 連続部分文字列
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-07-27 10:18:47 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 625 bytes | 
| コンパイル時間 | 1,817 ms | 
| コンパイル使用メモリ | 194,700 KB | 
| 最終ジャッジ日時 | 2025-01-07 09:35:30 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 30 WA * 11 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  string s;
  cin>>s;
  int n = s.size();
  double total = n*(n+1)/2;
  double sm = 0;
  double dp = 0;
  vector<int> used(26,-1);
  rep(i,n) {
    dp+=i-used[(int)(s[i]-'a')];
    sm += dp;
    used[(int)(s[i]-'a')]=i;
  }
  cout << (1.0*sm)/total << endl;
  return 0;
}