Submission #406387

#TimeUsernameProblemLanguageResultExecution timeMemory
406387atoizNicelines (RMI20_nicelines)C++14
Compilation error
0 ms0 KiB
#include <stdio.h> #include <math.h> #include <algorithm> #include <vector> #include "nice_lines.h" const int X = 100000; bool zero(long double x) { return std::abs(x) < 1; } bool equals(long double x, long double y) { return zero(x - y); } void add(int64_t Y, std::vector<int> &A, std::vector<int> &B) { int b = int(Y % X); while (b > 10000) b -= X; while (b < -10000) b += X; A.push_back((Y - b) / X), B.push_back(b); } int64_t round(long double x) { if (x < 0) return -int64_t(0.5 - x); else return int64_t(x + 0.5); } void solve_range(int64_t lo, long double dist_lo_0, long double dist_lo_1, int64_t hi, long double dist_hi_0, long double dist_hi_1, std::vector<int> &a, std::vector<int> &b) { long double diff_lo = (dist_lo_1 - dist_lo_0), diff_hi = (dist_hi_1 - dist_hi_0); if (lo >= hi) return; if (equals(dist_lo_0 + diff_lo * ((hi - lo) / 10000) * 0.25, dist_hi_0)) return; if (equals(dist_hi_0 + diff_hi * ((lo - hi) / 10000) * 0.25, dist_lo_0)) return; int64_t y = round(((dist_lo_0 * 40000 - diff_lo * lo) - (dist_hi_0 * 40000 - diff_hi * hi)) / (diff_hi - diff_lo)); // fprintf(stderr, "%lf\n", double(((dist_lo_0 * 40000 - diff_lo * lo) - (dist_hi_0 * 40000 - diff_hi * hi)) / (diff_hi - diff_lo))); long double dist_y = query(X, y - 20000); // fprintf(stderr, "%lf == %lf\n", double(dist_y * 40000), double(dist_lo_0 * 40000 + (y - lo) * diff_lo)); // fprintf(stderr, "%lf == %lf\n", double(dist_y * 40000), double(dist_hi_0 * 40000 + (y - hi) * diff_hi)); if (equals(dist_y * 40000, dist_lo_0 * 40000 + (y - lo) * diff_lo) && equals(dist_y * 40000, dist_hi_0 * 40000 + (y - hi) * diff_hi)) { add(y - 20000, a, b); return; } int64_t md = y - (y % 100000) + 50000 + (y % 100000 > 80000) * 100000; long double dist_md_0 = query(X, md - 20000); long double dist_md_1 = query(X, md + 20000); solve_range(lo, dist_lo_0, dist_lo_1, md, dist_md_0, dist_md_1, a, b); solve_range(md, dist_md_0, dist_md_1, hi, dist_hi_0, dist_hi_1, a, b); } void solve(int subtask_id, int N) { int64_t lo = -10000000000ll + 50000, hi = 10000000000ll + 50000; std::vector<int> a, b; solve_range(lo, query(X, lo - 20000), query(X, lo + 20000), hi, query(X, hi - 20000), query(X, hi + 20000), a, b); the_lines_are(a, b); }

Compilation message (stderr)

nicelines.cpp:20:28: error: 'int64_t round(long double)' conflicts with a previous declaration
   20 | int64_t round(long double x) {
      |                            ^
In file included from /usr/include/c++/10/math.h:36,
                 from nicelines.cpp:2:
/usr/include/c++/10/cmath:1760:3: note: previous declaration 'constexpr long double std::round(long double)'
 1760 |   round(long double __x)
      |   ^~~~~
nicelines.cpp: In function 'void solve_range(int64_t, long double, long double, int64_t, long double, long double, std::vector<int>&, std::vector<int>&)':
nicelines.cpp:31:115: error: call of overloaded 'round(long double)' is ambiguous
   31 |  int64_t y = round(((dist_lo_0 * 40000 - diff_lo * lo) - (dist_hi_0 * 40000 - diff_hi * hi)) / (diff_hi - diff_lo));
      |                                                                                                                   ^
In file included from /usr/include/features.h:461,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from nicelines.cpp:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:298:1: note: candidate: 'double round(double)'
  298 | __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
      | ^~~~~~~~~~~
In file included from /usr/include/c++/10/math.h:36,
                 from nicelines.cpp:2:
/usr/include/c++/10/cmath:1760:3: note: candidate: 'constexpr long double std::round(long double)'
 1760 |   round(long double __x)
      |   ^~~~~
/usr/include/c++/10/cmath:1756:3: note: candidate: 'constexpr float std::round(float)'
 1756 |   round(float __x)
      |   ^~~~~
nicelines.cpp:20:9: note: candidate: 'int64_t round(long double)'
   20 | int64_t round(long double x) {
      |         ^~~~~