답안 #942856

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942856 2024-03-11T05:25:27 Z Pannda Nicelines (RMI20_nicelines) C++17
62.0138 / 100
48 ms 2396 KB
#include "nice_lines.h"

#include <bits/stdc++.h>
using namespace std;

void solve(int subtask_id, int n) {
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    auto rand = [&](int l, int r) { return uniform_int_distribution<int>(l, r - 1)(rng); };
    const long double EPS = 1e-8;
    const int CL = -10000, CR = 10000;

    auto [a, b] = [&]() -> pair<vector<int>, vector<int>> {
        map<array<long long, 2>, long double> memorize;
        auto subquery = [&](long long x, long long y) {
            if (memorize.count({x, y})) return memorize[{x, y}];
            return memorize[{x, y}] = query(x, y);
        };
        auto f = [&](long long x, long long y) {
            return subquery(x, y + 1) - subquery(x, y);
        };
        vector<int> a, b;
        long long x = rand(30, 50);
        long long last = -5.1e7;
        for (int i = 0; i < n; i++) {
            long long l = last + 1, r = 5.1e7;
            while (l < r) {
                long long m = (l + r) >> 1;
                if (abs(f(x, m) - f(x, last)) > EPS) r = m;
                else l = m + 1;
            }
            long long y = l;
            long double d = abs(f(x, y) - f(x, last)) / 2;
            int _a = round(sqrt(1.0 / d / d - 1.0));
            int c = rand(1, 10);
            if (abs(f(x + c, y + c * _a) - f(x + c, y + c * _a - 1)) < EPS) _a *= -1;
            int _b = y - _a * x;
            a.push_back(_a);
            b.push_back(_b);
            last = y;
        }
        return make_pair(a, b);
    }();

    the_lines_are(a, b);
}

Compilation message

nicelines.cpp: In function 'void solve(int, int)':
nicelines.cpp:10:15: warning: unused variable 'CL' [-Wunused-variable]
   10 |     const int CL = -10000, CR = 10000;
      |               ^~
nicelines.cpp:10:28: warning: unused variable 'CR' [-Wunused-variable]
   10 |     const int CL = -10000, CR = 10000;
      |                            ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 436 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 436 KB Output is correct
4 Correct 1 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 440 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 456 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 43 ms 2396 KB Output is partially correct
2 Partially correct 40 ms 1652 KB Output is partially correct
3 Partially correct 45 ms 1204 KB Output is partially correct
4 Partially correct 41 ms 1992 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 14 ms 1492 KB Output is partially correct
2 Partially correct 13 ms 1992 KB Output is partially correct
3 Partially correct 12 ms 1480 KB Output is partially correct
4 Partially correct 13 ms 1036 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 43 ms 2396 KB Output is partially correct
2 Partially correct 40 ms 1652 KB Output is partially correct
3 Partially correct 45 ms 1204 KB Output is partially correct
4 Partially correct 41 ms 1992 KB Output is partially correct
5 Partially correct 14 ms 1492 KB Output is partially correct
6 Partially correct 13 ms 1992 KB Output is partially correct
7 Partially correct 12 ms 1480 KB Output is partially correct
8 Partially correct 13 ms 1036 KB Output is partially correct
9 Partially correct 39 ms 1808 KB Output is partially correct
10 Partially correct 44 ms 2008 KB Output is partially correct
11 Partially correct 48 ms 1572 KB Output is partially correct
12 Partially correct 45 ms 1460 KB Output is partially correct