結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
sinsincoscos
|
| 提出日時 | 2019-07-26 21:40:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 772 bytes |
| コンパイル時間 | 719 ms |
| コンパイル使用メモリ | 79,436 KB |
| 実行使用メモリ | 495,688 KB |
| 最終ジャッジ日時 | 2024-07-02 06:46:12 |
| 合計ジャッジ時間 | 8,535 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 MLE * 1 -- * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
string S;
cin >> S;
ll N = S.size();
vector<vector<ll>> ne(N+2,vector<ll>(26,N));
vector<vector<ll>> pre(N+2,vector<ll>(26,0));
for(int i=1;i<=N;i++){
for(int j=0;j<26;j++) pre[i][j] = pre[i-1][j];
pre[i][S[i-1]-'a'] = i;
}
for(int i=N;i>=1;i--){
for(int j=0;j<26;j++) ne[i][j] = ne[i+1][j];
ne[i][S[i-1]-'a'] = i;
}
ll ans = 0;
for(ll i=1;i<=N;i++){
ll l = i-pre[i-1][S[i-1]-'a'],r = N+1-i;
cerr << l << " " << r << endl;
ans += l*r;
}
// cout << ans << endl;
cout << fixed;
cout << setprecision(10) << (long double) ans/(N*(N+1)/2) << endl;
}
sinsincoscos