답안 #646133

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
646133 2022-09-28T18:26:16 Z pls33 Mobile (BOI12_mobile) C++17
8 / 100
1000 ms 41052 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma region dalykai
using p32 = pair<int, int>;
using p32u = pair<uint32_t, uint32_t>;
using p64 = pair<int64_t, int64_t>;
using p64u = pair<uint64_t, uint64_t>;
using vi16 = vector<int16_t>;
using vi16u = vector<uint16_t>;
using vi32 = vector<int>;
using vi32u = vector<uint32_t>;
using vi64 = vector<int64_t>;
using vi64u = vector<uint64_t>;
using vp32 = vector<p32>;
using vp32u = vector<p32u>;
using vp64 = vector<p64>;
using vp64u = vector<p64u>;
using vvi32 = vector<vi32>;
using vvi32u = vector<vi32u>;
using vvi64 = vector<vi64>;
using vvi64u = vector<vi64u>;
using vvp32 = vector<vp32>;
using vvp32u = vector<vp32u>;
using vvp64 = vector<vp64>;
using vvp64u = vector<vp64u>;

using pf32 = pair<float, float>;
using pf64 = pair<double, double>;
using pf80 = pair<long double, long double>;
using vf32 = vector<float>;
using vf64 = vector<double>;
using vf80 = vector<long double>;
using vpf32 = vector<pf32>;
using vpf64 = vector<pf64>;
using vpf80 = vector<pf80>;
using vvf32 = vector<vf32>;
using vvf64 = vector<vf64>;
using vvf80 = vector<vf80>;
using vvpf32 = vector<vpf32>;
using vvpf64 = vector<vpf64>;
using vvpf80 = vector<vpf80>;

template <typename key, typename val>
using ord_map = tree<key, val, less<key>, rb_tree_tag,
                     tree_order_statistics_node_update>;

template <typename key>
using ord_set = tree<key, null_type, less<key>, rb_tree_tag,
                     tree_order_statistics_node_update>;

const int BUF_SZ = 1 << 15;
inline namespace fast_in
{
    char buf[BUF_SZ];
    int pos;
    int len;

    char next_char(FILE *f)
    {
        if (pos == len)
        {
            pos = 0;
            len = (int)fread(buf, 1, BUF_SZ, f);

            if (!len)
            {
                return EOF;
            }
        }

        return buf[pos++];
    }

    int read_int(FILE *f)
    {
        int x;
        char ch;
        int sgn = 1;

        while (!isdigit(ch = next_char(f)))
        {
            if (ch == '-')
            {
                sgn *= -1;
            }
        }

        x = ch - '0';
        while (isdigit(ch = next_char(f)))
        {
            x = x * 10 + (ch - '0');
        }

        return x * sgn;
    }
}

/**
 * @brief gale programos flush_out kviest!!
 */
inline namespace fast_out
{
    char buf[BUF_SZ];
    int pos;

    void flush_out(FILE *f)
    {
        fwrite(buf, 1, pos, f);
        pos = 0;
    }

    void write_char(char c, FILE *f)
    {
        if (pos == BUF_SZ)
        {
            flush_out(f);
        }

        buf[pos++] = c;
    }

    void write_int(int x, FILE *f)
    {
        static char num_buf[100];

        if (x < 0)
        {
            write_char('-', f);
            x *= -1;
        }

        int len = 0;
        for (; x >= 10; x /= 10)
        {
            num_buf[len++] = (char)('0' + (x % 10));
        }

        write_char((char)('0' + x), f);
        while (len)
        {
            write_char(num_buf[--len], f);
        }
        write_char('\n', f);
    }
}
#pragma endregion

struct line_t
{
    int64_t k, m, p;
    bool operator<(const line_t &o) const { return k < o.k; }
    bool operator<(int64_t x) const { return p < x; }
    long long eval(long long x) const { return k * x + m; }
    double eval_d(double x) const { return k * x + m; }
};

struct cht_t
{
    deque<line_t> hull;

    int64_t div(int64_t a, int64_t b)
    {
        return floor(double(a) / b);
    }

    bool intersect(line_t &x, const line_t &y)
    {
        if (x.k == y.k)
        {
            x.p = x.m > y.m ? INT64_MAX : INT64_MIN;
        }
        else
        {
            x.p = div(y.m - x.m, x.k - y.k);
        }

        return x.p >= y.p;
    }

    void add(long long k, long long m)
    {
        line_t line = {k, m, 0};

        // wtf?
        while (hull.size() >= 2 &&
               (intersect(line, hull.back()),
                intersect(hull.back(), hull[(int)hull.size() - 2]),
                line.p < hull.back().p))
        {
            hull.pop_back();
        }

        hull.push_back(line);
    }

    int64_t query(int64_t x)
    {
        if (!hull.size())
        {
            return INT64_MAX;
        }
        while (hull.size() >= 2 && hull[0].eval(x) >= hull[1].eval(x))
        {
            hull.pop_front();
        }

        return hull[0].eval(x);
    }

    double query_d(double x)
    {
        if (!hull.size())
        {
            return INT64_MAX;
        }
        while (hull.size() >= 2 && hull[0].eval_d(x) >= hull[1].eval_d(x))
        {
            hull.pop_front();
        }

        return hull[0].eval_d(x);
    }
};

void add(p32 a, cht_t &cht)
{
    int64_t k = -2ll * a.first;
    int64_t m = (int64_t)a.first * a.first + (int64_t)a.second * a.second;

    cht.add(k, m);
}

long double distance(p32 a, p32 b)
{
    long double dx = a.first - b.first;
    long double dy = a.second - b.second;

    return sqrt(dx * dx + dy * dy);
}

int main()
{
#ifndef _AAAAAAAAA
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#else
    freopen("mobile.in", "r", stdin);
#ifndef __linux__
    atexit([]()
           {
        freopen("con", "r", stdin);
        system("pause"); });
#endif
#endif

    int n, length;
    cin >> n >> length;

    vp32 station(n);

    cht_t cht;
    for (auto &s : station)
    {
        cin >> s.first >> s.second;

        add(s, cht);
    }

    double dist = 0;
    double x = 0.0;
    for (size_t i = 0; i <= length * 1e3; i++)
    {
        double cur = cht.query_d(x) + x * x;

        dist = max(dist, cur);
        x += 1e-3;
    }

    cout << sqrt(dist) << '\n';

    return 0;
}

Compilation message

mobile.cpp:8: warning: ignoring '#pragma region dalykai' [-Wunknown-pragmas]
    8 | #pragma region dalykai
      | 
mobile.cpp:151: warning: ignoring '#pragma endregion ' [-Wunknown-pragmas]
  151 | #pragma endregion
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 316 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 4 ms 324 KB Output is correct
4 Correct 6 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 336 KB Output is correct
2 Execution timed out 1083 ms 444 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 340 KB Output is correct
2 Execution timed out 1082 ms 340 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 231 ms 440 KB Output is correct
2 Execution timed out 1077 ms 340 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1052 ms 1884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1620 KB Output is correct
2 Correct 130 ms 1648 KB Output is correct
3 Incorrect 668 ms 1976 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 833 ms 3840 KB Output is correct
2 Execution timed out 1078 ms 2132 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 2884 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 4044 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 20572 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1069 ms 12364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1078 ms 24740 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 14796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1080 ms 28800 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 17436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1044 ms 32896 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 19756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1074 ms 41052 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1047 ms 24664 KB Time limit exceeded
2 Halted 0 ms 0 KB -