Submission #698207

# Submission time Handle Problem Language Result Execution time Memory
698207 2023-02-12T21:07:02 Z randmac Mobile (BOI12_mobile) C++14
0 / 100
173 ms 16456 KB
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>
#include <math.h>
#include <iomanip>

using namespace std;

// https://oj.uz/problem/view/BOI12_mobile

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    // freopen("mobile.in", "r", stdin);
    // freopen("mobile.out", "w", stdout);

    int N, L;
    cin >> N >> L;

    vector<pair<int, int>> a(N);
    
    for (int i = 0; i < N; i++) {
        cin >> a[i].first >> a[i].second;
    }

    vector<pair<int, int>> b;
    int last_x = -1;
    for (auto it : a) {
        if (last_x != -1 && it.first == last_x) continue;
        b.push_back(it);
        last_x = it.first;
    }

    double ans = -1;
    for (int i = 0; i < b.size() - 1; i++) {
        int x_sum = b[i].first + b[i + 1].first;
        int x_diff = b[i + 1].first - b[i].first;

        double y_squared = (b[i + 1].second + b[i].second) * (b[i + 1].second - b[i].second);
        double x_0 = ( y_squared / x_diff + x_sum) / 2;
        double distance = (b[i].first - x_0) * (b[i].first - x_0) + b[i].second * b[i].second;
        ans = max(ans, distance);
    }

    // cout << sqrt(ans) << setprecision(4) << endl;
    cout << fixed << setprecision(4) << sqrt(ans) << endl;
}

Compilation message

mobile.cpp: In function 'int main()':
mobile.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int i = 0; i < b.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected double, but "inf" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Expected double, but "inf" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Expected double, but "inf" found
2 Halted 0 ms 0 KB -
# 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 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2068 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 944 KB Expected double, but "inf" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2176 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 1752 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 2256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 63 ms 8460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 90 ms 4364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 13316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 5028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 14100 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 5796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 102 ms 14888 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 144 ms 6592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 16456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 173 ms 8148 KB Output isn't correct
2 Halted 0 ms 0 KB -