結果
| 問題 |
No.852 連続部分文字列
|
| コンテスト | |
| ユーザー |
tempura_pp
|
| 提出日時 | 2019-03-29 16:49:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,596 bytes |
| コンパイル時間 | 1,071 ms |
| コンパイル使用メモリ | 104,492 KB |
| 実行使用メモリ | 5,424 KB |
| 最終ジャッジ日時 | 2024-11-07 01:18:12 |
| 合計ジャッジ時間 | 4,532 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 34 |
ソースコード
#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,5000){
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;
}
tempura_pp