//#include "nice_lines.h"
#include "bits/stdc++.h"
using namespace std;
long double query(long double x, long double y);
void the_lines_are(std::vector<int> a, std::vector<int> b);
int x = (1 << 15);
map<long long, long double> mem;
long double query(long long y) {
if (mem.find(y) != mem.end()) {
return mem[y];
}
return mem[y] = query(x, y);
}
pair<long double, long double> line(long long a, long long b) {
long double A = query(a);
long double B = query(b);
long double k = (B - A) / (b - a);
return {k, A - k * a};
}
long double intersection(pair<long double, long double> a, pair<long double, long double> b) {
return (a.second - b.second) / (b.first - a.first);
}
bool check(long long a, long long b, long long c) {
auto L = line(a, b);
auto R = line(b, c);
if (abs(L.first - R.first) < 1e-9) {
return true;
}
return false;
}
void solve(int subtask_id, int N) {
vector<int> res;
function<void(int, int, int, int)> solve = [&] (int l, int l1, int r, int r1) {
auto L = line(l, l1);
auto R = line(r, r1);
if (abs(L.first - R.first) < 1e-9) {
return;
}
long long X = round(intersection(L, R));
if (check(l, l1, X) && check(X, r, r1)) {
res.push_back(X);
return;
}
solve(l, l1, X - 1, X);
solve(X - 1, X, r, r1);
};
solve(-x * (1 << 14), -x * (1 << 14) + 1, x * (1 << 14) - 1, x * (1 << 14));
sort(res.begin(), res.end());
res.resize(unique(res.begin(), res.end()) - res.begin());
vector<int> a, b;
for (int i = 0; i < N; i++) {
int y = res[i] % x;
if (y < 0) {
y += x;
}
if (y >= x / 2) {
y -= x;
}
b.push_back(y);
a.push_back((res[i] - y) / x);
}
the_lines_are(a, b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
328 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
336 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
328 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |