QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#627540 | #5667. Meeting Places | KowerKoint# | WA | 25ms | 3880kb | C++20 | 2.4kb | 2024-10-10 16:15:54 | 2024-10-10 16:15:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int n, k; cin >> n >> k;
vector<ll> X(n), Y(n);
cin >> X[0];
auto gen = [&](ll x) {
return (x * (233811181) + 1) % ((1LL << 31) - 1);
};
Y[0] = gen(X[0]);
for(int i = 1; i < n; i++) {
X[i] = gen(Y[i-1]);
Y[i] = gen(X[i]);
}
auto cos = [&](int l, int r) {
auto calc = [&](double x, double y) {
double mx = 0.;
for(int i = l; i < r; i++) {
double dx = X[i]-x;
double dy = Y[i]-y;
double d = dx*dx+dy*dy;
if(mx < d) mx = d;
}
return mx;
};
double lx = 0, rx = (double)((1LL << 31) - 1);
constexpr int CNT = 50;
double EPS = 1e-8;
int xt = CNT;
auto sim_y = [&](double x) {
double ly = 0, ry = (double)((1LL << 31) - 1);
while(ry - ly > EPS*4) {
double ym = (ly+ry) / 2;
double y1 = ym - EPS;
double y2 = ym + EPS;
if(calc(x, y1) < calc(x, y2)) ry = y2;
else ly = y1;
}
return calc(x, ly);
};
while(rx - lx > EPS*4) {
double xm = (lx+rx) / 2;
double x1 = xm - EPS;
double x2 = xm + EPS;
if(sim_y(x1) < sim_y(x2)) rx = x2;
else lx = x1;
}
return sim_y(lx);
};
constexpr double INF = 4e18;
cout << fixed << setprecision(10);
if(n <= 50) {
vector cost(n+1, vector(n+1, INF));
for(int l = 0; l < n; l++) {
for(int r = l+1; r <= n; r++) {
cost[l][r] = sqrt(cos(l, r));
}
}
vector dp(k+1, vector(n+1, INF));
dp[0][0] = 0;
for(int i = 0; i < k; i++) {
for(int l = 0; l < n;l++) {
for(int r = l+1; r <= n; r++) {
double c = cost[l][r];
if(dp[i+1][r] > dp[i][l]+c) dp[i+1][r] = dp[i][l]+c;
}
}
}
cout << dp[k][n] << '\n';
return 0;
}
double ans = INF;
for(int l = 0; l+n-(k-1) <= n; l++) {
int r = l+n-(k-1);
double c = sqrt(cos(l, r));
if(ans > c) ans = c;
}
cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 25ms
memory: 3880kb
input:
100 23 213
output:
2805868567.2673468590
result:
wrong answer 1st numbers differ - expected: '1319350480.8007326', found: '2805868567.2673469', error = '1.1267045'