QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578779#5667. Meeting PlacesCelestialCoderWA 1ms20208kbC++202.8kb2024-09-20 21:15:232024-09-20 21:15:24

Judging History

你现在查看的是最新测评结果

  • [2024-09-20 21:15:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:20208kb
  • [2024-09-20 21:15:23]
  • 提交

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] = 1e15;
    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] = 1e15;
    }

    for (int i = 1; i <= K; ++i) {
        dnc(i, 0, N, 0, N - 1);
    }
    
    cout << fixed << setprecision(12);
    cout << dp[K][N];
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 20208kb

input:

100 23 213

output:

1319350480.800732538686

result:

ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 9864kb

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: 14016kb

input:

10 10 2373

output:

0.000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 11916kb

input:

10 2 3396

output:

1236610536.946923031239

result:

ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 9924kb

input:

10 3 1998

output:

973790809.822444227524

result:

ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 11968kb

input:

10 4 562

output:

910867389.906932937622

result:

ok found '910867389.9069330', expected '910867389.9069330', error '0.0000000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 14020kb

input:

10 5 6048

output:

818240814.710514981940

result:

ok found '818240814.7105150', expected '818240814.7105150', error '0.0000000'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 9920kb

input:

10 6 2524

output:

674787674.312985425000

result:

wrong answer 1st numbers differ - expected: '500106979.3467762', found: '674787674.3129854', error = '0.3492867'