QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#578769 | #5667. Meeting Places | CelestialCoder | WA | 2ms | 20132kb | C++20 | 2.8kb | 2024-09-20 21:12:32 | 2024-09-20 21:12:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const ll pr = 233811181;
const ll mod = (1ll<<31)-1;
struct Point {
ld x, y;
Point operator-(const Point& r)const {return Point{x-r.x, y-r.y};}
ld operator*(const Point& r) const {return x*r.x+y*r.y;}
ld operator^(const Point& r) const {return x*r.y-y*r.x;}
};
struct Circle{Point p; ld r;};
ld dst(Point a, Point b){
return sqrt((a-b)*(a-b));
}
const int MAX_N = 2000 + 1;
ld dp[MAX_N][MAX_N];
ld cost[MAX_N][MAX_N];
Point pp[MAX_N][MAX_N];
int ss[MAX_N][MAX_N];
Point getCenter(Point a, Point b){ return {(a.x+b.x)/2, (a.y+b.y)/2};}
Point getCenter(Point a, Point b, Point c){
Point aa = b - a, bb = c - a;
auto c1 = aa*aa * 0.5, c2 = bb*bb *0.5;
auto d = aa ^ bb;
auto x = a.x + (c1 * bb.y - c2 * aa.y) / d;
auto y = a.y + (c2 * aa.x - c1 * bb.x) / d;
return {x, y};
}
Circle solve(vector<Point> v, int s){
Point p = {0, 0};
ld r = 0;
int n = v.size();
for(int i=0; i<n; i++) {
if (dst(p, v[i]) > r) {
p = v[i];
r = 0;
for(int j=0; j<i; j++) {
if(dst(p, v[j]) > r) {
p = getCenter(v[i], v[j]);
r = dst(p, v[i]);
for(int k=0; k<j; k++) {
if(dst(p, v[k]) > r){
p = getCenter(v[i], v[j], v[k]);
r = dst(v[k], p);
}
}
}
}
}
pp[s][s+i] = p;
cost[s][s+i] = r;
}
return {p, r};
}
void dnc(int idx, int s, int e, int low, int high) {
if (s > e)
return;
int mid = s + e >> 1;
dp[idx][mid] = 1e18;
int opt = low;
for (int i = low; i < min(mid, high + 1); ++i) {
if (dp[idx][mid] > dp[idx - 1][i] + cost[i][mid - 1])
dp[idx][mid] = dp[idx - 1][i] + cost[i][mid - 1], opt = i;
}
dnc(idx, s, mid - 1, low, opt);
dnc(idx, mid + 1, e, opt, high);
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int N, K, X;
cin >> N >> K >> X;
vector <Point> input(N);
ll seed = X;
input[0].x = X;
input[0].y = seed = (seed*pr+1) % mod;
for(int i=1;i<N;i++){
input[i].x = seed = (seed*pr+1) % mod;
input[i].y = seed = (seed*pr+1) % mod;
}
for (int s=0; s<N; ++s) {
vector<Point> v(input.begin()+s, input.end());
solve(v, s);
}
for (int i = 1; i <= N; ++i) {
dp[0][i] = 1e18;
}
for (int i = 1; i <= K; ++i) {
dnc(i, 1, N, 0, N - 1);
}
cout << fixed << setprecision(12);
cout << dp[K][N - 1];
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 20132kb
input:
100 23 213
output:
1319350480.800732538686
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 9956kb
input:
10 1 1060
output:
1042753143.345167686581
result:
ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 11968kb
input:
10 10 2373
output:
0.000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 11980kb
input:
10 2 3396
output:
1236610536.946923031239
result:
ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 9992kb
input:
10 3 1998
output:
973790809.822444227524
result:
ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 2ms
memory: 9924kb
input:
10 4 562
output:
869475669.845396992634
result:
wrong answer 1st numbers differ - expected: '910867389.9069330', found: '869475669.8453970', error = '0.0454421'