結果

問題 No.852 連続部分文字列
ユーザー 1119_29161119_2916
提出日時 2019-08-01 17:45:50
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,668 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 172,460 KB
実行使用メモリ 4,572 KB
最終ジャッジ日時 2023-09-18 17:39:39
合計ジャッジ時間 8,630 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 474 ms
4,376 KB
testcase_34 AC 477 ms
4,376 KB
testcase_35 AC 475 ms
4,380 KB
testcase_36 AC 480 ms
4,380 KB
testcase_37 AC 476 ms
4,376 KB
testcase_38 AC 472 ms
4,376 KB
testcase_39 AC 475 ms
4,376 KB
testcase_40 AC 478 ms
4,376 KB
testcase_41 AC 474 ms
4,380 KB
testcase_42 AC 247 ms
4,376 KB
testcase_43 AC 296 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    string st;
    cin >> st;

    int n = st.size();
    
    vi pos(26, -1);
    vi cnt(27, 0);
    rep(i, n) {
        pos[st[i] - 'a'] = i;
        /*
        rep(j, pos.size()) {
            cout << pos[j] << " ";
        }
        cout << endl;
        */
        vi sorted = pos;
        sorted.emplace_back(0);
        sort(all(sorted));
        reverse(all(sorted));
        Rep(j, sorted.size()) {
            cnt[j] += sorted[j-1] - sorted[j];
        }
    }

    int sum = 0;
    rep(i, cnt.size()) {
        sum += cnt[i] * i;
        //std::cout << cnt[i] << std::endl;
    }

    cout << Decimal << (double)sum / (n * (n+1) / 2.0) << endl;

    return 0;
}
0