답안 #827885

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827885 2023-08-16T21:31:05 Z EntityPlantt Mobile (BOI12_mobile) C++14
0 / 100
1000 ms 131072 KB
#define ONLINE_JUDGE
#include <cstdio>
#include <cmath>
#include <vector>
#ifndef ONLINE_JUDGE
#include <windows.h>
const HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
inline void scta(const int &clr) { SetConsoleTextAttribute(handle, clr); }
#endif
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 > 2e-4) {
        m = (l + r) / 2.0;
        intervals.clear();
        intervals.push_back({0.0, len});
        #ifndef ONLINE_JUDGE
        scta(7);
        printf("l = %lf, r = %lf, m = %lf\n", l, r, m);
        #endif
        for (auto &point : points) {
            x = point.first;
            radius = sqrt(m * m - double(point.second) * double(point.second));
            #ifndef ONLINE_JUDGE
            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);
            #endif
            for (i = intervals.size() - 1; i >= 0; i--) {
                if (x - radius <= intervals[i].first && intervals[i].second <= x + radius) {
                    #ifndef ONLINE_JUDGE
                    scta(10);
                    printf("    Entire interval is contained\n");
                    #endif
                    intervals.erase(intervals.begin() + i);
                }
                else if (x + radius <= intervals[i].first || intervals[i].second <= x - radius) {
                    #ifndef ONLINE_JUDGE
                    scta(12);
                    printf("    None of the interval is contained\n");
                    #endif
                }
                else if (x - radius <= intervals[i].first && x + radius <= intervals[i].second) {
                    #ifndef ONLINE_JUDGE
                    scta(9);
                    printf("    The left part of the interval is contained\n");
                    #endif
                    intervals[i].first = x + radius;
                }
                else if (intervals[i].first <= x - radius && intervals[i].second <= x + radius) {
                    #ifndef ONLINE_JUDGE
                    scta(13);
                    printf("    The right part of the interval is contained\n");
                    #endif
                    intervals[i].second = x - radius;
                }
                else {
                    #ifndef ONLINE_JUDGE
                    scta(11);
                    printf("    The interval has to be split into two\n");
                    #endif
                    intervals.push_back({x + radius, intervals[i].second});
                    intervals[i].second = x - radius;
                }
            }
            if (intervals.empty()) break; // Everything covered, number too big
        }
        if (intervals.empty()) r = m; else l = m;
    }
    printf("%lf", l);
    return 0;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d%d%d%d", &n, &len, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         scanf("%d%d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1054 ms 4488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 2476 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 4596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 8680 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 113 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 121 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1067 ms 1668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2124 KB Output is correct
2 Correct 15 ms 1988 KB Output is correct
3 Runtime error 115 ms 131072 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 2384 KB Output is correct
2 Correct 17 ms 2128 KB Output is correct
3 Runtime error 121 ms 131072 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 2592 KB Output is correct
2 Correct 17 ms 2116 KB Output is correct
3 Runtime error 126 ms 131072 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 157 ms 8484 KB Output is correct
2 Correct 68 ms 8140 KB Output is correct
3 Correct 70 ms 7672 KB Output is correct
4 Execution timed out 1040 ms 30236 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 8616 KB Output is correct
2 Runtime error 193 ms 131072 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 176 ms 13240 KB Output is correct
2 Correct 80 ms 9600 KB Output is correct
3 Correct 89 ms 9088 KB Output is correct
4 Execution timed out 1043 ms 29072 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 10268 KB Output is correct
2 Runtime error 216 ms 131072 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 218 ms 13288 KB Output is correct
2 Correct 109 ms 11160 KB Output is correct
3 Correct 103 ms 10484 KB Output is correct
4 Execution timed out 1055 ms 35812 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 108 ms 11884 KB Output is correct
2 Runtime error 249 ms 131072 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 277 ms 13504 KB Output is correct
2 Correct 122 ms 12800 KB Output is correct
3 Correct 123 ms 11904 KB Output is correct
4 Execution timed out 1067 ms 55176 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 125 ms 13520 KB Output is correct
2 Runtime error 254 ms 131072 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 16856 KB Output is correct
2 Correct 155 ms 15876 KB Output is correct
3 Correct 131 ms 14940 KB Output is correct
4 Execution timed out 1055 ms 31096 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 16856 KB Output is correct
2 Runtime error 288 ms 131072 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -