Submission #133149

# Submission time Handle Problem Language Result Execution time Memory
133149 2019-07-20T07:59:59 Z win11905 Mobile (BOI12_mobile) C++11
0 / 100
274 ms 10844 KB
#include <bits/stdc++.h>
#define pii pair<int, int>
#define x first
#define y second
using namespace std;
 
int n, k;
vector<pii> vec;
 
double dist(pii p, double x) {
    return hypot((double)p.x - x, (double)p.y);
}
 
double f(double x) { return x * x; }
 
double getx(pii p1, pii p2) {
    double x1 = p1.x, x2 = p2.x, y1 = p1.y, y2 = p2.y;
    return (f(x2) + f(y2) - f(x1) - f(y1)) / (2 * (x2 - x1));
}
 
int main() {
    scanf("%d %d", &n, &k);
    for(int i = 0, x, y; i < n; ++i) {
        scanf("%d %d", &x, &y);
        if(vec.empty()) vec.emplace_back(x, abs(y));
        else if(vec.back().x == x) vec.back().y = min(vec.back().y, abs(y));
        else vec.emplace_back(x, abs(y));
    }
    deque<pii> stk;
    stk.emplace_back(vec[0]), stk.emplace_back(vec[1]);
    for(int i = 2; i < vec.size(); ++i) {
        while(stk.size() >= 2 && getx(stk.back(), vec[i]) > getx(stk[stk.size()-2], vec[i])) stk.pop_back();
        stk.emplace_back(vec[i]);
    }
    while(stk.size() >= 2 && getx(stk[0], stk[1]) < 0) stk.pop_front();
    while(stk.size() >= 2 && getx(stk[stk.size()-2], stk.back()) > k) stk.pop_back();
    double ans = 0;
    ans = max(ans, dist(stk[0], 0));
    ans = max(ans, dist(stk.back(), k));
    for(int i = 1; i < stk.size(); ++i) {
        double x = getx(stk[i], stk[i-1]);
        ans = max(ans, dist(stk[i], x));
    }
    printf("%.6f\n", ans);
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 2; i < vec.size(); ++i) {
                    ~~^~~~~~~~~~~~
mobile.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 1; i < stk.size(); ++i) {
                    ~~^~~~~~~~~~~~
mobile.cpp:22:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &k);
     ~~~~~^~~~~~~~~~~~~~~~~
mobile.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &x, &y);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 2288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2160 KB Output is correct
2 Incorrect 26 ms 2032 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 2164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 2548 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 116 ms 6656 KB Output is correct
2 Correct 130 ms 2728 KB Output is correct
3 Incorrect 127 ms 1400 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 131 ms 2808 KB Output is correct
2 Incorrect 136 ms 5476 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 142 ms 10752 KB Output is correct
2 Incorrect 151 ms 2268 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 2600 KB Output is correct
2 Incorrect 167 ms 9564 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 10716 KB Output is correct
2 Incorrect 180 ms 2308 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 2460 KB Output is correct
2 Incorrect 192 ms 9372 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 185 ms 10844 KB Output is correct
2 Incorrect 202 ms 2168 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 209 ms 2312 KB Output is correct
2 Incorrect 217 ms 9432 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 230 ms 10560 KB Output is correct
2 Incorrect 255 ms 2040 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 255 ms 536 KB Output is correct
2 Incorrect 274 ms 9424 KB Output isn't correct
3 Halted 0 ms 0 KB -