#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double,double> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
#define x first
#define y second
const double EPS = 1e-8;
double dist(pll a, pll b) {
double in = (a.x-b.x)*(a.x-b.x) + (a.y-b.y)+(a.y-b.y);
return sqrt(in);
}
pair<pll,double> maxDist(vpll v) {
double ans = 0;
pll a = v[0];
for (pll i : v) {
for (pll j : v) {
double res = dist(i,j);
if (res > ans) {
ans = res;
a = {(i.x+j.x)/2,(i.y+j.y)/2};
}
}
}
return {a,ans};
}
vpll ok(int n, int m, vpll v, double k) {
vpll ans;
int ind = 0;
while (ind < n) {
int cur = ind, prev = cur;
while (cur < n-1 && maxDist(vpll(v.begin()+ind,v.begin()+cur+1)).y <= 2*k) {
prev = cur;
int dif = cur-ind+1;
cur = min(cur+dif, n-1);
}
ll lo = prev, hi = cur;
while (lo < hi) {
ll mid = (lo+hi+1)/2;
auto p = maxDist(vpll(v.begin()+ind, v.begin()+mid+1));
if (p.y <= 2*k) lo = mid;
else hi = mid-1;
}
ans.push_back(maxDist(vpll(v.begin()+ind, v.begin()+lo+1)).x);
ind = lo+1;
}
return ans.size() <= m ? ans : vpll();
}
int main() {
int n, m; cin >> n >> m;
vpll v(n);
for (pll &p : v) cin >> p.x >> p.y;
double lo = 0, hi = 1e18;
while (hi-lo > EPS) {
double mid = (hi+lo)/2;
if (ok(n,m,v,mid).size()) hi = mid;
else lo = mid;
}
cout << hi << '\n';
vpll ans = ok(n,m,v,hi);
cout << fixed << setprecision(7);
cout << ans.size() << '\n';
for (pll p : ans) cout << p.x << ' ' << p.y << '\n';
}
Compilation message
wyk.cpp: In function 'vpll ok(int, int, vpll, double)':
wyk.cpp:52:23: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
52 | return ans.size() <= m ? ans : vpll();
| ~~~~~~~~~~~^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Nieprawidlowa wartosc r |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
14 ms |
336 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1239 ms |
464 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1214 ms |
336 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1180 ms |
336 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2371 ms |
472 KB |
Nieprawidlowa wartosc r |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
30034 ms |
648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
30048 ms |
2892 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
30034 ms |
4968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
30043 ms |
4960 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
30039 ms |
4968 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |