QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#345937 | #8305. Accelerator | black_moonrise# | WA | 12ms | 182172kb | C++14 | 1.9kb | 2024-03-07 17:27:29 | 2024-03-07 17:27:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5;
#define MP make_pair
#define PB push_back
#define ff first
#define ss second
const int maxn = 211;
double calc(int up, int down, int l, int r) {
// (0, l) -> (1, r) intersect [down, up]
if(l >= r) swap(l, r);
down = max(down, l);
up = min(up, r);
if(up <= down) return 0.0;
double q1 = 1.0 * (r - up) / (r - l);
double q2 = 1.0 * (r - down) / (r - l);
return (q1 + q2) * (up - down) / 2;
}
double f[211][1024], dp[211][211][512];
int n, h[211], W, H;
int main() {
printf("hehe %.10lf\n", calc(0, 5, 0, 5));
scanf("%d%d%d", &n, &W, &H);
for(int i=1; i<=n; i++) scanf("%d", h+i);
for(int i=0; i<=n; i++) {
for(int j=0; j<(1<<W*2); j++) {
vector<pair<int, int> > vs;
for(int k=0; k<W*2; k++) if((j >> k) & 1) {
// [i - W+ 1, i + W]
int pos = i + W - k;
if(pos >= 0 && pos <= n+1) {
vs.emplace_back(h[pos] - H, h[pos] + H);
}
}
sort(vs.begin(), vs.end());
int cur = -1e9;
for(auto v : vs) {
// max(v.ff, cur) -> v.ss
if(cur < v.ss) {
f[i][j] += calc(max(cur, v.ff), v.ss, h[i], h[i+1]);
cur = v.ss;
}
}
}
}
for(int i=0; i<211; i++) for(int j=0; j<211; j++) for(int k=0; k<512; k++) dp[i][j][k] = -1e100;
dp[1][0][0] = 0.0;
int tot_mask = (1 << W*2) - 1;
for(int i=1; i<=n + W; i++) {
for(int j=0; j<i; j++) {
for(int mask=0; mask<(1<<W*2-1); mask++) {
if(dp[i][j][mask] < 0) continue;
// decided: [i - W*2 + 1, i]
for(int t=0; t<1 + (i <= n); t++) {
int nmask = (mask * 2 + t) & tot_mask;
dp[i+1][j+t][nmask] = min(dp[i+1][j+t][nmask], dp[i][j][mask] + (i >= W ? f[i-W][mask*2+t] : 0));
}
}
}
}
printf("n= %d\n", n);
for(int j=1; j<=n; j++) {
double ans = 0;
for(int k=0; k<(1<<W*2-1); k++) {
ans = max(ans, dp[n+W][j][k]);
}
printf("%.10lf\n", ans);
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 182172kb
input:
3 3 1 2 3 1 10 4 5 5 5 5
output:
hehe 0.0000000000 n= 3 0.0000000000 0.0000000000 0.0000000000
result:
wrong answer 1st lines differ - expected: '665496247', found: 'hehe 0.0000000000'