답안 #829328

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
829328 2023-08-18T09:25:45 Z rainboy Nicelines (RMI20_nicelines) C++17
11 / 100
99 ms 1444 KB
#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, ul1, ul2, 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 1 ms 284 KB Output is correct
4 Correct 0 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Incorrect 97 ms 1444 KB Incorrect
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 1268 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Wrong query
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 1348 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Wrong query
2 Halted 0 ms 0 KB -