이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 5003
int n ,l;
int x[MAX_N] ,y[MAX_N];
vector <pair<double ,double>> rngs;
double dist(int x ,int y ,double p){
return sqrt(1.0*y*y + 1.0*(p-x)*(p-x));
}
double get_min(double p){
double ret = DBL_MAX;
for(int i=0; i<n; i++)
ret = min(ret ,dist(x[i] ,y[i] ,p));
return ret;
}
double fnd_rng(double st ,double en ,int i ,bool le){
double mid;
for(int ee=100; ee; ee--){
mid = (st+en)/2;
if(get_min(mid)-dist(x[i] ,y[i] ,mid) >= 0)
(le ? en = mid : st = mid);
else
(le ? st = mid : en = mid);
}
return le ? en : st;
}
double naive(){
double ans = DBL_MIN;
for(double i=0; i<=l; i+=0.0001)
ans = max(ans ,get_min(i));
return ans;
}
int main()
{
scanf("%d%d",&n,&l); assert(n < MAX_N);
//n = 10 ,l = 20;
//printf("%d %d\n",n,l);
for(int i=0; i<n; i++)
scanf("%d%d",&x[i],&y[i]);
/*{x[i] = (rand()%20)*(rand()%5 ? +1 : -1) ,y[i] = (rand()%20)*(rand()%5 ? +1 : -1);
printf("%d %d\n",x[i],y[i]);}*/
double ans = DBL_MIN;
for(int i=0; i<n; i++)
{
double st = fnd_rng(0 ,x[i] ,i ,1);
double en = fnd_rng(x[i] ,l ,i ,0);
if(en-st>1e-7)
ans = max(ans ,max(dist(x[i] ,y[i] ,st) ,dist(x[i] ,y[i] ,en)));
}
cout << fixed << setprecision(6) << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
mobile.cpp: In function 'int main()':
mobile.cpp:40:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&n,&l); assert(n < MAX_N);
~~~~~^~~~~~~~~~~~~~
mobile.cpp:44:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&x[i],&y[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |