QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#94886 | #5667. Meeting Places | pedroteosousa# | WA | 2ms | 13924kb | C++20 | 3.2kb | 2023-04-08 03:44:06 | 2023-04-08 03:44:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
const long long MOD = 2147483647;
using coord = long double;
coord EPS = 1e-8;
namespace basic {
#define X real()
#define Y imag()
using point = complex<coord>;
int signal(coord x) {
return (x > EPS) - (x < -EPS);
}
point rotate90(point p) {
return p * point(0, 1);
}
coord dot(point a, point b) {
return (conj(a) * b).X;
}
coord cross(point a, point b) {
return (conj(a) * b).Y;
}
struct line {
point p;
coord c;
line(point a, point b): p(rotate90(b - a)), c(dot(p, a)) {}
};
bool intersects(line l1, line l2) {
return signal(cross(l1.p, l2.p));
}
point intersection(line l1, line l2) {
if (!intersects(l1, l2)) throw 1;
point p(cross({l1.c, l1.p.Y}, {l2.c, l2.p.Y}), cross({l1.p.X, l1.c}, {l2.p.X, l2.c}));
return p / cross(l1.p, l2.p);
}
struct circle {
point c;
coord r;
};
bool contains(circle c, point p) {
return abs(p - c.c) <= c.r + EPS;
}
circle create(point u, point v, point w) {
point mv = (u + v) / 2.0L;
point mw = (u + w) / 2.0L;
line s(mv, mv + rotate90(v - u));
line t(mw, mw + rotate90(w - u));
point c = intersection(s, t);
coord r = abs(c - u);
return {c, r};
}
};
using namespace basic;
pair<point, long long> next(long long x) {
long long y = (233811181ll * x + 1) % MOD;
point p = {(long double)x, (long double)y};
return {p, (233811181ll * y + 1) % MOD};
}
long double dp[N][N], cost[N][N];
vector<int> pos[N];
void calc(vector<point> &p) {
int n = p.size();
for (int l = 0; l < n; l++) {
int i, j, k;
circle c = {p[l], 0};
for (i = l; i < n; i++) {
if (contains(c, p[i])) {
cost[l][i] = c.r;
continue;
};
for (c = {p[i], 0}, j = l; j < i; j++) {
if (contains(c, p[j])) continue;
for (c = {(p[i] + p[j]) / 2.0L, abs(p[i] - p[j]) / 2}, k = l; k < j; k++) {
if (contains(c, p[k])) continue;
c = create(p[i], p[j], p[k]);
}
}
cost[l][i] = c.r;
}
}
}
int main() {
long long n, K, x; scanf("%lld %lld %lld", &n, &K, &x);
vector<point> p(n);
for (int i = 0; i < n; i++) {
auto pp = next(x);
x = pp.second;
p[i] = pp.first;
}
calc(p);
for (int i = 0; i < n; i++) {
dp[i][1] = cost[0][i];
}
for (int i = 0; i < n; i++) {
long double last = cost[0][i];
for (int j = 1; j <= i; j++) {
long double nc = cost[j][i];
if (nc + EPS < last) {
last = nc;
pos[i].push_back(j);
}
}
}
for (int k = 2; k <= K; k++) {
for (int i = 0; i < n; i++) {
dp[i][k] = cost[0][i];
for (int j = 0; j < pos[i].size(); j++) {
int pp = pos[i][j];
dp[i][k] = min(dp[i][k], dp[pp - 1][k - 1] + cost[pp][i]);
}
}
}
printf("%.10lf\n", dp[n - 1][K]);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 13924kb
input:
100 23 213
output:
0.0000000000
result:
wrong answer 1st numbers differ - expected: '1319350480.8007326', found: '0.0000000', error = '1.0000000'