#include "nice_lines.h"
#include <cmath>
#include <vector>
using namespace std;
typedef long double ld;
typedef vector<int> vi;
const int N = 100;
const int M = 10000;
const int X = 10000000;
const ld eps = 1e-9;
vi aa, bb;
void solve_(int al, ld ul1, ld ul2, int ar, ld ur1, ld ur2) {
long long y1 = (long long) (al + 1) * X - M, y2 = (long long) ar * X + M;
long long y = roundl(((X - M * 2) * (ur1 - ul2) + y1 * (ul2 - ul1) - y2 * (ur2 - ur1)) / ((ul2 - ul1) - (ur2 - ur1)));
int a = roundl((ld) y / X), b = y - (long long) a * X;
ld u1 = query(X, (long long) (a - 1) * X + M), u2 = query(X, (long long) a * X - M);
if (fabsl(((u2 - u1) - (ul2 - ul1)) / (X - M * 2)) > eps)
solve_(al, ul1, ul2, a - 1, u1, u2), solve_(a - 1, u1, u2, ar, ur1, ur2);
else if (((ur2 - ur1) - (ul2 - ul1)) / (X - M * 2) > (1 / sqrt(a * a + 1)) * 2 + eps) {
ld v1 = query(X, (long long) a * X + M), v2 = query(X, (long long) (a + 1) * X - M);
solve_(a, v1, v2, ar, ur1, ur2);
al = a - 1, ul1 = u1, ul2 = u2, ar = a, ur1 = v1, ur2 = v2;
y1 = (long long) (al + 1) * X - M, y2 = (long long) ar * X + M;
y = roundl(((X - M * 2) * (ur1 - ul2) + y1 * (ul2 - ul1) - y2 * (ur2 - ur1)) / ((ul2 - ul1) - (ur2 - ur1)));
a = roundl((ld) y / X), b = y - (long long) a * X;
aa.push_back(a), bb.push_back(b);
} else
aa.push_back(a), bb.push_back(b);
}
void solve(int subtask_id, int n) {
int al = -(M + 1);
ld ul1 = query(X, (long long) al * X + M), ul2 = query(X, (long long) (al + 1) * X - M);
int ar = M;
ld ur1 = query(X, (long long) ar * X + M), ur2 = query(X, (long long) (ar + 1) * X - M);
aa.clear(), bb.clear(), solve_(al, ul1, ul2, ar, ur1, ur2);
the_lines_are(aa, bb);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
288 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
304 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
288 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 |
Correct |
7 ms |
304 KB |
Output is correct |
2 |
Correct |
6 ms |
208 KB |
Output is correct |
3 |
Correct |
5 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
2 ms |
288 KB |
Output is correct |
7 |
Correct |
2 ms |
208 KB |
Output is correct |
8 |
Correct |
2 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
300 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
11 |
Correct |
5 ms |
300 KB |
Output is correct |
12 |
Correct |
3 ms |
300 KB |
Output is correct |