이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const long long precision = 1e4; // TO not to deal with double/float precision problems
const int MAXN = 1e6+5;
//long long stations[MAXN][2];
vector < vector<long double> > stations;
int main()
{
long double n, length;
cin >> n >> length;
//length *= precision;
for(int i = 1; i <= n; i++)
{
long double x, y;
cin >> x >> y;
//x *= precision;
//y *= precision;
if(stations.size() == 0 || (stations.back())[0] != x)
stations.push_back({x, y});
else
{
vector<long double> elem = stations.back();
if(abs(elem[1]) > abs(y))
{
stations.pop_back();
stations.push_back({x, y});
}
}
/*cin >> stations[i][0] >> stations[i][1];
stations[i][0] *= precision;
stations[i][1] *= precision;*/
}
long double l = 0, r = 3e9, ans = 3e9; // Max distance will be 3e9 as we can we have 2e9 vertical and 2e9 horizontal distance so according to the pythagoran sqrt(2e9^2 + 2e9^2) = 2e9 * sqrt(2)
while(r - l >= 0.00001)
{
long double m = (l + r) / 2.00000;
long double left = length, right = 0;
for(int i = 0; i < stations.size(); i++)
{
long double x = stations[i][0], y = stations[i][1];
//cout << x << " " << y << "\n";
if(abs(y) > m)
continue;
long double horizontal = sqrt((m * m) - (y * y));
//cout << x << " " << y << " " << m << " " << horizontal << "\n";
if(x <= 0)
{
if(x + horizontal >= 0)
{
left = 0, right = max(right, (long double) (x + horizontal));
}
} else
{
long double templeft = max((long double)0.00000, (long double)(x - horizontal));
long double tempright = min(length, (long double)(x + horizontal));
if(templeft <= right)
{
left = min(left, max((long double)0.00000, templeft));
right = max(right, min(length, tempright));
}
}
}
if(left <= 0 && right >= length)
{
ans = m;
r = m - 0.00001;
} else
l = m + 0.00001;
}
cout << fixed << setprecision(10) << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
mobile.cpp: In function 'int main()':
mobile.cpp:46:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | for(int i = 0; i < stations.size(); 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... |