Submission #19427282


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k;
  cin >> k;
  vector<double> r(1 << k);
  for(auto &e: r) cin >> e;
  vector dp(1 << k, vector(k + 1, 0.0));
  for(int i=0; i<(1<<k); i++) dp[i][0] = 1.0;
  auto prob = [&](int win, int lose){return 1.0 / (1 + pow(10, (r[lose] - r[win]) / 400));};
  auto is_Left = [](int idx, int pw){return (idx % pw) * 2 < pw;};
  int pw = 1;
  for(int round=0; round<k; round++){
    pw *= 2;
    for(int i=0; i<(1<<k); i++){
      int l = i / pw * pw;
      int r = l + pw;
      if(is_Left(i, pw)) l += pw / 2;
      else r -= pw / 2;
      for(int j=l; j<r; j++){
        dp[i][round+1] += dp[i][round] * dp[j][round] * prob(i, j);
      }
    }
  }
  cout << fixed << setprecision(10);
  for(int i=0; i<(1<<k); i++) cout << dp[i][k] << endl;
}

Submission Info

Submission Time
Task C - トーナメント
User yahoobb
Language C++ (GCC 9.2.1)
Score 4
Code Size 826 Byte
Status AC
Exec Time 78 ms
Memory 4236 KB

Judge Result

Set Name All
Score / Max Score 4 / 4
Status
AC × 6
Set Name Test Cases
All 00, 01, 02, 03, 90, 91
Case Name Status Exec Time Memory
00 AC 78 ms 4184 KB
01 AC 70 ms 4236 KB
02 AC 19 ms 3864 KB
03 AC 71 ms 4220 KB
90 AC 2 ms 3884 KB
91 AC 2 ms 4016 KB