QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#123445 | #5667. Meeting Places | GenshinImpactsFault# | WA | 308ms | 20260kb | C++14 | 4.9kb | 2023-07-12 16:35:18 | 2023-07-12 16:35:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define MOD ((1ll << 31) - 1)
int X[2010], Y[2010];
long double p[2010][2010];
long double dis[2010][2010];
long double get_dis(int x1, int y1, int x2, int y2) {
long double ret = sqrt(1ll * (x1 - x2) * (x1 - x2) + 1ll * (y1 - y2) * (y1 - y2));
return ret;
}
long double f[2010][2010];
#define fst first
#define snd second
#define pb push_back
typedef pair<long double, long double> pii;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
inline pii operator+(const pii &x, const pii &y) {
return {x.fst + y.fst, x.snd + y.snd};
}
inline pii operator-(const pii &x, const pii &y) {
return {x.fst - y.fst, x.snd - y.snd};
}
long double len(const pii &x) {
return sqrt(x.fst * x.fst + x.snd * x.snd);
}
pii dir(const pii &x) {
return (pii){x.fst / len(x), x.snd / len(x)};
}
long double angle(const pii &x) {
pii y = dir(x);
if(x.snd >= 0) return acos(y.fst);
return 2 * pi - acos(y.fst);
}
pii a[2010];
struct P {
long double x, y, r;
};
P calc(int lb, int rb) {
int u = lb;
for(int i = lb; i <= rb; i++) a[i] = {X[i], Y[i]};
vector<long double> ad, rm;
long double l = 0, r = INT_MAX, mid;
pii cen, tmp;
for(; r - l > eps;) {
mid = (l + r) / 2;
int cnt = 1, flag = 0;
ad.clear(), rm.clear();
for(int i = lb; i <= rb; i++) {
if(i == u) continue;
long double le = len(a[i] - a[u]), r1 = mid, r2 = mid;
if(le + r1 <= r2) {
assert(0);
}
if(le + r2 < r1 || r1 + r2 < le) continue;
long double theta = angle(a[i] - a[u]), delta, tx, ty;
delta = acos((r1 * r1 + le * le - r2 * r2) / 2 / r1 / le);
tx = theta - delta, ty = theta + delta;
for(; tx < 0; tx += 2 * pi, ty += 2 * pi);
if(ty <= 2 * pi) {
ad.pb(tx), rm.pb(ty);
}
else {
ad.pb(tx), rm.pb(2 * pi), ad.pb(0), rm.pb(ty - 2 * pi);
}
}
sort(ad.begin(), ad.end()), sort(rm.begin(), rm.end());
for(auto it1 = ad.begin(), it2 = rm.begin(); it1 != ad.end() || it2 != rm.end();) {
if(it1 != ad.end() && (it2 == rm.end() || *it1 < *it2)) {
tmp = a[u] + (pii){cos(*it1) * mid, sin(*it1) * mid};
++cnt, ++it1;
}
else --cnt, ++it2;
if(cnt >= rb - lb + 1) {
flag = 1; break;
}
}
if(flag) cen = tmp, r = mid;
else l = mid;
}
return (P){cen.fst, cen.snd, r};
}
vector<pair<int, long double>> from[2010];
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n, K;
cin >> n >> K >> X[1];
for(int i = 1; i <= n; ++ i) {
if(i > 1) {
X[i] = ((Y[i - 1] * 233811181ll) + 1) % MOD;
}
Y[i] = ((X[i] * 233811181ll) + 1) % MOD;
}
for(int i = 1; i <= n; ++ i) {
for(int j = i; j <= n; ++ j) {
dis[i][j] = dis[j][i] = get_dis(X[i], Y[i], X[j], Y[j]);
}
}
for(int i = 1; i <= n; ++ i) {
P now = calc(i - 1, i);
p[i - 1][i] = now.r;
from[i].push_back({i - 1, 0});
from[i].push_back({i - 2, p[i - 1][i]});
for(int j = i - 2; j >= 1; -- j) {
if(now.r * now.r >= (X[j] - now.x) * (X[j] - now.x) + (Y[j] - now.y) * (Y[j] - now.y)) {
p[j][i] = p[j + 1][i];
from[i][from[i].size() - 1].first = j - 1;
}
else {
now = calc(j, i);
p[j][i] = now.r;
from[i].push_back({j - 1, p[j][i]});
}
// p[i][j] = p[i][j - 1];
// for(int k = i; k <= j - 1; ++ k) {
// p[i][j] = max(p[i][j], dis[k][j]);
// }
// cerr << i << " " << j << " " << p[i][j] << endl;
}
}
if(K <= 50) {
for(int i = 0; i <= n; ++ i) {
for(int j = 0; j <= n; ++ j) {
f[i][j] = 1e18;
}
}
f[0][0] = 0;
for(int i = 1; i <= n; ++ i) {
for(int j = 1; j <= K && j <= i; ++ j) {
// f[i][j] = 1e15;
for(auto [k, pp] : from[i]) {
f[i][j] = min(f[i][j], f[k][j - 1] + pp);
}
f[i][j] = min(f[i][j], f[j - 1][j - 1] + p[j][i]);
// for(int k = 0ll; k <= i - 1; ++ k) {
// // if(i == 1 && j == 1) {
// // cerr << p[k + 1][i] << endl;
// // }
// f[i][j] = min(f[i][j], f[k][j - 1] + p[k + 1][i]);
// }
// if(i <= 20) cerr << i << " " << j << " " << f[i][j] << endl;
}
}
cout << fixed << setprecision(20) << f[n][K] << endl;
}
else {
long double mx = 1e18;
for(int i = 1; i <= n && i + n - K <= n; ++ i) {
mx = min(mx, p[i][i + n - K]);
}
cout << fixed << setprecision(20) << mx << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 102ms
memory: 16400kb
input:
100 23 213
output:
1319350480.80073254485614597797
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 9956kb
input:
10 1 1060
output:
1042753143.34516769286710768938
result:
ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 7796kb
input:
10 10 2373
output:
0.00000000000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #4:
score: 0
Accepted
time: 3ms
memory: 9872kb
input:
10 2 3396
output:
1236610536.94692303542979061604
result:
ok found '1236610536.9469230', expected '1236610536.9469230', error '0.0000000'
Test #5:
score: 0
Accepted
time: 3ms
memory: 7796kb
input:
10 3 1998
output:
973790809.82244423299562186003
result:
ok found '973790809.8224442', expected '973790809.8224442', error '0.0000000'
Test #6:
score: 0
Accepted
time: 3ms
memory: 7908kb
input:
10 4 562
output:
910867389.90693294338416308165
result:
ok found '910867389.9069330', expected '910867389.9069330', error '0.0000000'
Test #7:
score: 0
Accepted
time: 1ms
memory: 7792kb
input:
10 5 6048
output:
818240814.71051498549059033394
result:
ok found '818240814.7105150', expected '818240814.7105150', error '0.0000000'
Test #8:
score: 0
Accepted
time: 3ms
memory: 7920kb
input:
10 6 2524
output:
500106979.34677624536561779678
result:
ok found '500106979.3467762', expected '500106979.3467762', error '0.0000000'
Test #9:
score: 0
Accepted
time: 2ms
memory: 7800kb
input:
10 7 5415
output:
559478971.43200589169282466173
result:
ok found '559478971.4320059', expected '559478971.4320059', error '0.0000000'
Test #10:
score: 0
Accepted
time: 3ms
memory: 7968kb
input:
10 8 1438
output:
500309745.46276999928522855043
result:
ok found '500309745.4627700', expected '500309745.4627700', error '0.0000000'
Test #11:
score: 0
Accepted
time: 3ms
memory: 9936kb
input:
10 9 3172
output:
162279748.87534517564927227795
result:
ok found '162279748.8753452', expected '162279748.8753452', error '0.0000000'
Test #12:
score: 0
Accepted
time: 136ms
memory: 18272kb
input:
100 1 8316
output:
1320052902.15229025902226567268
result:
ok found '1320052902.1522903', expected '1320052902.1522903', error '0.0000000'
Test #13:
score: 0
Accepted
time: 193ms
memory: 13948kb
input:
100 100 4179
output:
0.00000000000000000000
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #14:
score: 0
Accepted
time: 214ms
memory: 18268kb
input:
100 12 3405
output:
1329687126.13045487995259463787
result:
ok found '1329687126.1304548', expected '1329687126.1304548', error '0.0000000'
Test #15:
score: 0
Accepted
time: 160ms
memory: 14172kb
input:
100 16 8378
output:
1338056514.48426947603002190590
result:
ok found '1338056514.4842694', expected '1338056514.4842694', error '0.0000000'
Test #16:
score: 0
Accepted
time: 140ms
memory: 20220kb
input:
100 2 1858
output:
1310392496.14305806858465075493
result:
ok found '1310392496.1430581', expected '1310392496.1430581', error '0.0000000'
Test #17:
score: 0
Accepted
time: 115ms
memory: 20068kb
input:
100 25 4596
output:
1440464106.62292967201210558414
result:
ok found '1440464106.6229296', expected '1440464106.6229298', error '0.0000000'
Test #18:
score: 0
Accepted
time: 186ms
memory: 16460kb
input:
100 3 5633
output:
1399621082.61427368433214724064
result:
ok found '1399621082.6142738', expected '1399621082.6142738', error '0.0000000'
Test #19:
score: 0
Accepted
time: 179ms
memory: 16064kb
input:
100 32 7827
output:
1342073760.53223296953365206718
result:
ok found '1342073760.5322330', expected '1342073760.5322330', error '0.0000000'
Test #20:
score: 0
Accepted
time: 163ms
memory: 20260kb
input:
100 4 3693
output:
1339808706.70986888394691050053
result:
ok found '1339808706.7098689', expected '1339808706.7098689', error '0.0000000'
Test #21:
score: 0
Accepted
time: 265ms
memory: 18516kb
input:
100 5 2252
output:
1394874243.50570420734584331512
result:
ok found '1394874243.5057042', expected '1394874243.5057042', error '0.0000000'
Test #22:
score: 0
Accepted
time: 149ms
memory: 18208kb
input:
100 50 4254
output:
1322809748.40528354560956358910
result:
ok found '1322809748.4052835', expected '1322809748.4052832', error '0.0000000'
Test #23:
score: 0
Accepted
time: 166ms
memory: 16432kb
input:
100 6 53
output:
1364441356.17009879788383841515
result:
ok found '1364441356.1700988', expected '1364441356.1700988', error '0.0000000'
Test #24:
score: 0
Accepted
time: 106ms
memory: 16180kb
input:
100 64 4337
output:
1180754550.24228390725329518318
result:
ok found '1180754550.2422838', expected '1180754550.2422838', error '0.0000000'
Test #25:
score: 0
Accepted
time: 183ms
memory: 20236kb
input:
100 7 5366
output:
1423557626.35867970669642090797
result:
ok found '1423557626.3586798', expected '1423557626.3586798', error '0.0000000'
Test #26:
score: 0
Accepted
time: 105ms
memory: 16228kb
input:
100 8 8509
output:
1353289305.35199556779116392136
result:
ok found '1353289305.3519955', expected '1353289305.3519957', error '0.0000000'
Test #27:
score: 0
Accepted
time: 308ms
memory: 16272kb
input:
100 9 1423
output:
1228887266.56616696575656533241
result:
ok found '1228887266.5661669', expected '1228887266.5661671', error '0.0000000'
Test #28:
score: 0
Accepted
time: 218ms
memory: 16192kb
input:
100 91 4806
output:
656574218.50867548829410225153
result:
ok found '656574218.5086755', expected '656574218.5086756', error '0.0000000'
Test #29:
score: 0
Accepted
time: 159ms
memory: 16008kb
input:
100 92 4024
output:
794693428.61622404074296355247
result:
ok found '794693428.6162241', expected '794693428.6162238', error '0.0000000'
Test #30:
score: -100
Wrong Answer
time: 200ms
memory: 14144kb
input:
100 93 606
output:
786201505.59027904924005270004
result:
wrong answer 1st numbers differ - expected: '677641787.4863122', found: '786201505.5902791', error = '0.1602022'