結果

問題 No.852 連続部分文字列
ユーザー tempura_pptempura_pp
提出日時 2019-03-21 03:20:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,654 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 102,912 KB
実行使用メモリ 52,352 KB
最終ジャッジ日時 2024-04-24 16:39:58
合計ジャッジ時間 15,586 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
24,064 KB
testcase_01 AC 15 ms
24,064 KB
testcase_02 AC 15 ms
24,064 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 AC 15 ms
24,064 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 WA -
testcase_14 RE -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 547 ms
52,224 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 AC 553 ms
52,352 KB
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 RE -
testcase_31 WA -
testcase_32 AC 554 ms
52,224 KB
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


struct Xor128{
    unsigned x,y,z,w;
 
    Xor128(unsigned w_=88675123):x(123456789),y(362436069),z(521288629),w(w_){};
 
    inline unsigned xor128(){
        unsigned t;
        t = x^(x<<11);
        x = y;
        y = z;
        z = w;
        return w = (w^(w>>19))^(t^(t>>8));
    }
 
    int nextInt(int x,int y){
		if(x>y)swap(x,y);
        return xor128()%(y-x)+x;
    }
 
    double nextDouble(double a,double b){
        return (double)(xor128()&0xffff)/0xffff*(b-a)+a;
    }
 
};
int main(){
    string s;
    cin>>s;
    ll n=s.size();
    auto rnd=Xor128();
    set<ll> st;
    ll sum=0;
    ll cumsum[100001][26];
    rep(i, 100000) rep(j, 26) cumsum[i + 1][j] = cumsum[i][j] + (s[i] - 'a' == j ? 1 : 0);
    rep(i,600000){
        int l=rnd.nextInt(0, n);
        int r=rnd.nextInt(1, n+1);
        if(l==r)continue;
        if(l>r)swap(l,r);
        if(st.count(n*r+l))continue;
        st.insert(n*r+l);
        int cnt=0;
        rep(j, 26) if (cumsum[r][j] - cumsum[l][j] > 0) ++ cnt;
        sum+=cnt;
        if(st.size()==n*(n+1)/2)break;
    }
    cout<<1.0*sum/st.size()<<endl;

    return 0;
}
0