이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 f = [&](long long x, long long y) {
if (memorize.count({x, y})) return memorize[{x, y}];
return memorize[{x, y}] = query(x, y + 1) - query(x, y);
};
vector<int> a, b;
long long x = rand(1, 90);
long long last = -1e6;
for (int i = 0; i < n; i++) {
long long l = last + 1, r = 1e6;
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);
}
컴파일 시 표준 에러 (stderr) 메시지
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;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |