QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#732923 | #5667. Meeting Places | nekoyellow | WA | 0ms | 3896kb | C++23 | 2.9kb | 2024-11-10 16:28:48 | 2024-11-10 16:28:49 |
Judging History
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: 0
Wrong Answer
time: 0ms
memory: 3896kb
input:
100 23 213
output:
213 409657673 1964978180 1990106379 462028685 1997989469 2042892580 1474689195 1127287735 1785763830 412529718 61896425 1395684931 1810772202 211208746 1476543482 834661499 214972278 144032760 533222845 771438511 1063173596 1167055992 32151573 1898795394 2020102950 738758679 973155176 1353173565 147...
result:
wrong answer 1st numbers differ - expected: '1319350480.8007326', found: '213.0000000', error = '0.9999998'