QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#578540#5667. Meeting PlacesCelestialCoder#WA 4ms22876kbC++202.7kb2024-09-20 19:53:182024-09-20 19:53:19

Judging History

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

  • [2024-09-20 19:53:19]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:22876kb
  • [2024-09-20 19:53:18]
  • 提交

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; double r;};
long double 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};
    double 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};
}

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 n=0; n<N; ++n) {
        dp[n][1] = cost[0][n];
        for (int k=2; k<=min(K, n+1); ++k) { 
            if (dst(pp[ss[n-1][k]][n-1], input[n]) < cost[ss[n-1][k]][n-1]) {
                dp[n][k] = dp[n-1][k];
                ss[n][k] = ss[n-1][k];
            } else {
                dp[n][k] = 1e18;
                for (int t=k-1; t<n; ++t) {
                    dp[n][k] = min(dp[n][k], dp[t][k-1] + cost[t+1][n]);
                    ss[n][k] = t+1;
                }
            }
        }
    }
    cout << fixed << setprecision(12) << dp[N-1][K];
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 22876kb

input:

100 23 213

output:

1319350480.800732612610

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 9936kb

input:

10 1 1060

output:

1042753143.345167636871

result:

ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'

Test #3:

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

input:

10 10 2373

output:

0.000000000000

result:

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

Test #4:

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

input:

10 2 3396

output:

1000000000000000000.000000000000

result:

wrong answer 1st numbers differ - expected: '1236610536.9469230', found: '1000000000000000000.0000000', error = '808662039.4099964'