Submission #828426

#TimeUsernameProblemLanguageResultExecution timeMemory
828426rainboyNicelines (RMI20_nicelines)C11
33.18 / 100
30 ms284 KiB
#include "nice_lines_c.h" #include <math.h> #define N 100 #define M 10000 #define X (M * 2 + 1) #define Y ((long long) M * X + M + 1) typedef long double ld; 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 (fabsl((z - z1) / (y - y1) - (z2 - z1)) < 1e-12) 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...