Submission #828469

# Submission time Handle Problem Language Result Execution time Memory
828469 2023-08-17T10:06:02 Z rainboy Nicelines (RMI20_nicelines) C
0 / 100
35 ms 288 KB
#include "nice_lines_c.h"
 
#define N	100
#define M	10000
#define X	(M * 2 + 1)
#define Y	((long long) M * X + M + 1)
 
typedef long double ld;
 
ld abs_(ld a) { return a > 0 ? a : -a; }
ld max(ld a, ld b) { return a > b ? a : b; }

long double error(long double a, long double b) {
	return abs_(a - b) / max(abs_(b), 1);
}

void solve(int subtask_id, int n) {
	static int aa[N], bb[N];
	long long y, y1, lower, upper, a, b;
	ld z, z1, z2;
	int i;
 
	y1 = -Y, z1 = query(X, y1), z2 = query(X, y1 + 1);
	for (i = 0; i < n; i++) {
		lower = y1, upper = Y + 1;
		while (upper - lower > 1) {
			y = (lower + upper) / 2;
			z = query(X, y);
			if (error(z1 + (z2 - z1) * (y - y1), z) < 1e-6)
				lower = y;
			else
				upper = y;
		}
		y1 = lower, z1 = query(X, y1), z2 = query(X, y1 + 1);
		a = lower / X, b = y1 - a * X;
		while (b > M)
			a++, b -= X;
		while (b < -M)
			a--, b += X;
		aa[i] = a, bb[i] = b;
	}
	the_lines_are(aa, bb);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 288 KB Output is correct
2 Incorrect 1 ms 208 KB Incorrect
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Incorrect 1 ms 208 KB Incorrect
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Incorrect 1 ms 208 KB Incorrect
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 35 ms 208 KB Incorrect
2 Halted 0 ms 0 KB -