QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#732925#5667. Meeting PlacesnekoyellowWA 1ms4040kbC++232.9kb2024-11-10 16:29:292024-11-10 16:29:31

Judging History

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

  • [2024-11-10 16:29:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4040kb
  • [2024-11-10 16:29:29]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll M = (1ll << 31) - 1;
const double eps = 1e-8;

int sgn(double x) {
    if (fabs(x) < eps) return 0;
    return x < 0 ? -1 : 1;
}

struct Point {
    double x, y;
    Point() {}
    Point(ll x, ll y) : x(x), y(y) {}
};

double dist(Point a, Point b) {
    return hypot(a.x - b.x, a.y - b.y);
}

Point center(Point a, Point b, Point c) {
    Point cen;
    double a1 = b.x - a.x, b1 = b.y - a.y, c1 = (a1*a1 + b1*b1)/2;
    double a2 = c.x - a.x, b2 = c.y - a.y, c2 = (a2*a2 + b2*b2)/2;
    double d = a1*b2 - a2*b1;
    cen.x = a.x + (c1*b2 - c2*b1)/d;
    cen.y = a.y + (a1*c2 - a2*c1)/d;
    return cen;
}

void minc(const vector<Point> &p, Point &c, double &r) {
    int n = p.size();
    c = p[0], r = 0;
    for (int i = 1; i < n; i++) {
        if (sgn(dist(p[i], c) - r) > 0) {
            c = p[i], r = 0;
            for (int j = 0; j < i; j++) {
                if (sgn(dist(p[j], c) - r) > 0) {
                    c.x = (p[i].x + p[j].x)/2;
                    c.y = (p[i].y + p[j].y)/2;
                    r = dist(p[j], c);
                    for (int k = 0; k < j; k++) {
                        if (sgn(dist(p[k], c) - r) > 0) {
                            c = center(p[i], p[j], p[k]);
                            r = dist(p[i], c);
                        }
                    }
                }
            }
        }
    }
}

ll f(ll x) {
    return (x * 233811181 + 1) % M;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int n, k;
    cin >> n >> k;
    int len = n-k+1;

    vector<ll> x(n), y(n);
    cin >> x[0];
    y[0] = f(x[0]);

    for (int i = 1; i < n; i++) {
        x[i] = f(y[i-1]);
        y[i] = f(x[i]);
    }

    // for (int i = 0; i < n; i++) {
    //     cout << x[i] << ' ' << y[i] << endl;
    // }

    double ans = numeric_limits<double>::max();

    for (int i = 0; i+len <= n; i++) {
        vector<Point> p;
        for (int j = 0; j < len; j++) {
            p.push_back({x[i+j], y[i+j]});
        }
        Point c; double r;
        minc(p, c, r);
        ans = min(ans, r);
    }

    if (len > 2) {
        len--;
        for (int i = 0; i+len <= n; i++) {
            vector<Point> p;
            for (int j = 0; j < len; j++) {
                p.push_back({x[i+j], y[i+j]});
            }
            Point c; double r;
            minc(p, c, r);
            for (int j = 0; j+1 < len; j++) {
                if (j+1 >= i && j < i+len) continue;
                vector<Point> np;
                np.push_back({x[j], y[j]});
                np.push_back({x[j+1], y[j+1]});
                Point nc; double nr;
                minc(np, nc, nr);
                ans = min(ans, r + nr);
            }
        }
    }

    cout << fixed << setprecision(12) << ans << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3972kb

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

input:

10 1 1060

output:

1042753143.345167636871

result:

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

Test #3:

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

input:

10 10 2373

output:

0.000000000000

result:

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

Test #4:

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

input:

10 2 3396

output:

1236610536.946923017502

result:

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

Test #5:

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

input:

10 3 1998

output:

973790809.822444200516

result:

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

Test #6:

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

input:

10 4 562

output:

910867389.906933069229

result:

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

Test #7:

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

input:

10 5 6048

output:

818240814.710515022278

result:

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

Test #8:

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

input:

10 6 2524

output:

500106979.346776306629

result:

ok found '500106979.3467763', expected '500106979.3467762', error '0.0000000'

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3892kb

input:

10 7 5415

output:

610069091.024019956589

result:

wrong answer 1st numbers differ - expected: '559478971.4320059', found: '610069091.0240200', error = '0.0904236'