Submission #827894

# Submission time Handle Problem Language Result Execution time Memory
827894 2023-08-16T21:50:33 Z EntityPlantt Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 131072 KB
#define ONLINE_JUDGE
#include <cstdio>
#include <cmath>
#include <vector>
/*#include <windows.h>
const HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
inline void scta(const int &clr) { SetConsoleTextAttribute(handle, clr); }*/
using namespace std;
vector <pair <int, int>> points;
vector <pair <double, double>> intervals;
double radius;
int n, len, x, y, i;
double l, r = 2e9, m;
int main() {
    scanf("%d%d%d%d", &n, &len, &x, &y);
    points.push_back({x, abs(y)});
    while (--n) {
        scanf("%d%d", &x, &y);
        /*if (points.back().first == x) {
            if (y < 0) {
                points.back().second = -y;
            }
        }
        else*/ points.push_back({x, y});
    }
    while (r - l > 1e-8) {
        m = (l + r) / 2.0;
        intervals.clear();
        intervals.push_back({0.0, len});
        /*scta(7);
        printf("l = %lf, r = %lf, m = %lf\n", l, r, m);*/
        for (auto &point : points) {
            x = point.first;
            radius = sqrt(m * m - double(point.second) * double(point.second));
            /*scta(15);
            printf("  Intervals =");
            scta(14);
            for (auto &in : intervals) {
                printf(" (%lf, %lf)", in.first, in.second);
            }
            scta(15);
            printf("\n  place = %d, radius = %lf\n", x, radius);*/
            for (i = intervals.size() - 1; i >= 0; i--) {
                if (x - radius <= intervals[i].first && intervals[i].second <= x + radius) {
                    // scta(10); printf("    Entire interval is contained\n");
                    intervals.erase(intervals.begin() + i);
                }
                else if (x + radius <= intervals[i].first || intervals[i].second <= x - radius) {
                    // scta(12); printf("    None of the interval is contained\n");
                }
                else if (x - radius <= intervals[i].first && x + radius <= intervals[i].second) {
                    // scta(9); printf("    The left part of the interval is contained\n");
                    intervals[i].first = x + radius;
                }
                else if (intervals[i].first <= x - radius && intervals[i].second <= x + radius) {
                    // scta(13); printf("    The right part of the interval is contained\n");
                    intervals[i].second = x - radius;
                }
                else {
                    // scta(11); printf("    The interval has to be split into two\n");
                    intervals.push_back({x + radius, intervals[i].second});
                    intervals[i].second = x - radius;
                }
            }
            if (intervals.empty()) break;
        }
        if (intervals.empty()) r = m; else l = m;
    }
    printf("%lf\n", l);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     scanf("%d%d%d%d", &n, &len, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         scanf("%d%d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 4432 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 2504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 2480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 185 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 113 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 127 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 33820 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1416 KB Output is correct
2 Correct 22 ms 1356 KB Output is correct
3 Runtime error 123 ms 131072 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1077 ms 1340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 39 ms 1432 KB Output is correct
2 Correct 28 ms 1368 KB Output is correct
3 Runtime error 126 ms 131072 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1061 ms 4420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 4412 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1071 ms 8528 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 8540 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1064 ms 8520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 8496 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 8524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1072 ms 8548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1070 ms 8512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1075 ms 8624 KB Time limit exceeded
2 Halted 0 ms 0 KB -