Submission #660487

# Submission time Handle Problem Language Result Execution time Memory
660487 2022-11-22T03:57:53 Z SansPapyrus683 Mobile (BOI12_mobile) C++17
0 / 100
1000 ms 32588 KB
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>

// #include "debugging.hpp"

using std::cout;
using std::endl;
using std::vector;
using Point = std::pair<double, double>;

constexpr int PRECISION = 4;

double dist(const Point& p1, const Point& p2) {
    double dx = p1.first - p2.first;
    double dy = p1.second - p2.second;
    return std::sqrt(dx * dx + dy * dy);
}

double min_dist(double road_pos, const vector<Point>& towers) {
    double ret = dist({road_pos, 0}, towers[0]);
    for (int i = 1; i < towers.size(); i++) {
        ret = std::max(ret, dist({road_pos, 0}, towers[i]));
    }
    return ret;
}

/**
 * https://oj.uz/problem/view/BOI12_mobile
 * 2 10
 * 0 0
 * 11 1 should output something close to 5.545455
 */
int main() {
    int tower_num;
    int road_len;
    std::cin >> tower_num >> road_len;
    
    vector<Point> towers(tower_num);
    for (Point& t : towers) {
        std::cin >> t.first >> t.second;
    }

    long long div_by = std::pow(10, PRECISION);
    long long lo = 0;
    long long hi = (long long) road_len * div_by;
    while (lo <= hi) {
        long long mid = (lo + hi) / 2;  // this shouldn't overflow
        long long next = mid + 1;
        double mid_val = min_dist((double) mid / div_by, towers);
        double next_val = min_dist((double) next / div_by, towers);
        if (mid_val < next_val) {
            hi = mid - 1;
        } else {
            lo = mid + 1;
        }
    }

    cout << std::fixed << std::setprecision(PRECISION)
         << (double) lo / div_by << endl;
}

Compilation message

mobile.cpp: In function 'double min_dist(double, const std::vector<std::pair<double, double> >&)':
mobile.cpp:24:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<double, double> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for (int i = 1; i < towers.size(); 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 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 420 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 2252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 2144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 77 ms 2292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 124 ms 3504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 137 ms 3372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 489 ms 12412 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 663 ms 16308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 580 ms 14792 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 779 ms 19536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 690 ms 17556 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 906 ms 22916 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 771 ms 19728 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1016 ms 26032 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 951 ms 24652 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1089 ms 32588 KB Time limit exceeded
2 Halted 0 ms 0 KB -