Contest Duration: ~ (local time) (300 minutes) Back to Home

Submission #12285583

Source Code Expand

Copy
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

signed main(void) {
int n;
cin >> n;
vvi a(n,vi(6));
vi num;//座圧用配列
rep(i,n)rep(j,6){
cin >> a[i][j];
num.push_back(a[i][j]);
}

//座圧
sort(all(num));
num.erase(unique(all(num)),num.end());

int max_number = num.size();
vvi dice(max_number+1);//dice[i]:=出目がiのサイコロのindex
rep(i,n)rep(j,6){
int ind = lower_bound(all(num),a[i][j]) - num.begin();//座圧後のindex
dice[ind+1].push_back(i);//1-indexedにする
}

vector<double> dp(max_number+1,0),exp(n,0);
double max_exp = 0;
for(int i = max_number; i >= 0; i--){
dp[i] = max_exp + 1;
rep(j,dice[i].size()){
//サイコロdice[i][j]に出目iが書かれている
exp[dice[i][j]] += dp[i]/6.0;
max_exp = max(max_exp, exp[dice[i][j]]);
}
}

cout << shosu(10) << dp[0] << endl;
}

#### Submission Info

Submission Time 2020-04-25 11:37:55+0900 O - Endurance rika0384 C++14 (GCC 5.4.1) 6 2038 Byte AC 148 ms 15732 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_01.txt, example_02.txt
Case Name Status Exec Time Memory
example_01.txt 1 ms 256 KB
example_02.txt 1 ms 256 KB