結果

問題 No.852 連続部分文字列
ユーザー tempura_pptempura_pp
提出日時 2019-03-29 16:48:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,598 bytes
コンパイル時間 1,124 ms
コンパイル使用メモリ 104,296 KB
実行使用メモリ 14,092 KB
最終ジャッジ日時 2024-04-24 16:39:30
合計ジャッジ時間 13,934 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,540 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 11 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
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 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 TLE -
権限があれば一括ダウンロードができます

ソースコード

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;
    rep(i,200000){
        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;
        vector<int> c(26);
        REP(i,l,r){
            if(++c[s[i]-'a']==1)++cnt;
            if(cnt==26)break;
        }
        sum+=cnt;
        if(st.size()==n*(n+1)/2)break;
    }
    cout<<1.0*sum/st.size()<<endl;

    return 0;
}
0