Submission #11377564
Source Code Expand
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int n,max_x=0;
ld dp[(1 << 20)];
ld get_dp(int S){
//cout << bitset<10>(S) << endl;
if(S==0) return 0;
if(dp[S]!=-1) return dp[S];
ld res=0;
int nex1=0,nex2=0;
int s=0;
rep(i,max_x+1){
if(S&(1 << i)){
s=i;
if(S&(1 << (i+1))) nex1=1;
if(S&(1 << (i+2))) nex2=1;
break;
}
}
//cout << s << endl;
if(nex1==1 && nex2==1){
res+=get_dp(S^(1 << s))/3;
res+=get_dp(S^(1 << (s+1)))/3;
res+=get_dp(S^(1 << (s+2)))/3;
res-=1;
}
if(nex1==1 && nex2==0){
res+=get_dp(S^(1 << s))/2;
res+=get_dp(S^(1 << (s+1)))/2;
res-=1.5;
}
if(nex1==0 && nex2==1){
res+=get_dp(S^(1 << s))/2;
res+=get_dp(S^(1 << (s+2)))/2;
res-=1.5;
}
if(nex1==0 && nex2==0){
res+=get_dp(S^(1 << s));
res-=3;
}
dp[S]=res;
//cout << bitset<10>(S) << " " << dp[S] << endl;
return res;
}
void solve(){
cin >> n;
int T=0;
rep(i,n){
int x;cin >> x;
max_x=max(max_x,x);
T+=(1 << x);
}
rep(i,(1 << 19)){
dp[i]=-1;
}
dp[0]=0;
cout << -get_dp(T) << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(50);
solve();
}
Submission Info
Submission Time |
|
Task |
J - ボール |
User |
Chanyuh |
Language |
C++14 (GCC 5.4.1) |
Score |
5 |
Code Size |
2391 Byte |
Status |
AC |
Exec Time |
5 ms |
Memory |
10496 KB |
Judge Result
Set Name |
All |
Score / Max Score |
5 / 5 |
Status |
|
Set Name |
Test Cases |
All |
00, 01, 02, 03, 90, 91 |
Case Name |
Status |
Exec Time |
Memory |
00 |
AC |
5 ms |
10496 KB |
01 |
AC |
5 ms |
10496 KB |
02 |
AC |
5 ms |
10496 KB |
03 |
AC |
5 ms |
10496 KB |
90 |
AC |
5 ms |
10496 KB |
91 |
AC |
5 ms |
10496 KB |