Submission #6418696
Source Code Expand
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>
#include<math.h>
typedef int32_t i32;
#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define POS(i, j) (((i) & 1) * (1 << n) + (j))
void run (void) {
i32 n;
scanf ("%" SCNi32, &n);
i32 *a = ALLOC (1 << n, i32);
for (i32 i = 0; i < (1 << n); ++i) {
scanf ("%" SCNi32, a + i);
}
const i32 m = 4000;
double *p = ALLOC (2 * m + 1, double) + m;
for (i32 i = -m; i <= m; ++i) {
p[i] = 1 / (1 + pow (10, (double) i / 400));
}
double *dp = ALLOC (2 * (1 << n), double);
for (i32 i = 0; i < (1 << n); ++i) {
dp[POS(0, i)] = 1;
}
for (i32 i = 1; i <= n; ++i) {
memset (dp + POS(i, 0), 0, sizeof (double) * (1 << n));
for (i32 j = 0; j < (1 << n); j += 1 << i) {
for (i32 l = j; l < j + (1 << (i - 1)); ++l) {
for (i32 r = j + (1 << (i - 1)); r < j + (1 << i); ++r) {
i32 x = a[r] - a[l];
dp[POS(i, l)] += dp[POS(i - 1, r)] * p[x];
dp[POS(i, r)] += dp[POS(i - 1, l)] * p[-x];
}
}
}
for (i32 j = 0; j < (1 << n); ++j) {
dp[POS(i, j)] *= dp[POS(i - 1, j)];
}
}
for (i32 i = 0; i < (1 << n); ++i) {
printf ("%.7f\n", dp[POS(n, i)]);
}
}
int main (void) {
run();
return 0;
}
Submission Info
Submission Time
2019-07-17 22:49:59+0900
Task
C - トーナメント
User
sansen
Language
C (GCC 5.4.1)
Score
4
Code Size
1365 Byte
Status
AC
Exec Time
3 ms
Memory
256 KB
Compile Error
./Main.c: In function ‘run’:
./Main.c:16:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%" SCNi32, &n);
^
./Main.c:19:5: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%" SCNi32, a + i);
^
Judge Result
Set Name
All
Score / Max Score
4 / 4
Status
Set Name
Test Cases
All
00, 01, 02, 03, 90, 91
Case Name
Status
Exec Time
Memory
00
AC
3 ms
256 KB
01
AC
3 ms
256 KB
02
AC
3 ms
256 KB
03
AC
3 ms
256 KB
90
AC
1 ms
256 KB
91
AC
1 ms
256 KB