結果
問題 | No.852 連続部分文字列 |
ユーザー |
|
提出日時 | 2019-07-27 10:19:12 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 6 ms / 3,153 ms |
コード長 | 612 bytes |
コンパイル時間 | 1,924 ms |
コンパイル使用メモリ | 193,828 KB |
最終ジャッジ日時 | 2025-01-07 09:35:40 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#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;ll n = s.size();ll total = n*(n+1)/2;ll sm = 0;ll 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;}