結果
| 問題 | No.852 連続部分文字列 |
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-08-02 05:29:04 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 1,326 ms / 3,153 ms |
| コード長 | 854 bytes |
| 記録 | |
| コンパイル時間 | 3,114 ms |
| コンパイル使用メモリ | 279,580 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-07-01 22:38:54 |
| 合計ジャッジ時間 | 19,204 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=998244353;
ll inf=100990999999999909;
int main(){
string s;
cin >> s;
vector<ll>memo(100,-1);
ll ans=0;
for (ll i = 0; i < s.size(); i++)
{
map<ll,ll>mm;
ll now=0;
memo[s[i]-'a']=max(memo[s[i]-'a'],i);
for (char c = 'a'; c <='z'; c++)
{
if (memo[c-'a']!=-1)
{
now++;
mm[memo[c-'a']]++;
}
}
ll pre=-1;
for(auto v:mm){
ans+=now*(v.first-pre);
pre=v.first;
now--;
}
}
ll n=s.size();
ll x=(n*(n+1))/2;
ld y=ans;
ld z=x;
cout << setprecision(100) << y/z << endl;
}
hiro71687k