Submission #942662

#TimeUsernameProblemLanguageResultExecution timeMemory
942662CDuongNicelines (RMI20_nicelines)C++17
11 / 100
31 ms440 KiB
#include "nice_lines.h" #include <bits/stdc++.h> #define taskname "" #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define i64 long long #define pb push_back #define ff first #define ss second #define isz(x) (int)x.size() using namespace std; const int mxN = 2e5 + 5; const int mod = 1e9 + 7; const long double eps = 1e-8; const i64 oo = 1e18; void solve1() { long double xl = -1e12, xr = 1e12; for (int i = 1; i <= 1000; ++i) { long double midl = xl + (xr - xl) / 3; long double midr = xr - (xr - xl) / 3; // cout << midl << " " << midr << endl; // cout << query(midl, 0) << " " << query(midr, 0) << endl; if (query(midl, 0) >= query(midr, 0)) xl = midl; else xr = midr; } auto x0 = xl; xl = -1e12, xr = 1e12; for (int i = 1; i <= 1000; ++i) { long double midl = xl + (xr - xl) / 3; long double midr = xr - (xr - xl) / 3; if (query(midl, 1) >= query(midr, 1)) xl = midl; else xr = midr; } auto x1 = xl; // cout << x0 << " " << x1 << endl; auto cr_diff = abs(query(x0, 0) - query(x1, 1)) - 1; if (-eps <= cr_diff and cr_diff <= eps) { if (query(x0, 0) < query(x1, 1)) the_lines_are({0}, {-round(query(x0, 0))}); else the_lines_are({0}, {round(query(x1, 1)) + 1}); return; } auto slope = 1.0L / (x1 - x0); auto other = -x0 * slope; the_lines_are({round(slope)}, {round(other)}); } void solve(int subtask_id, int N) { if (subtask_id == 1) { solve1(); return; } }

Compilation message (stderr)

nicelines.cpp: In function 'void solve1()':
nicelines.cpp:40:62: warning: narrowing conversion of '- std::round(query(x0, (long double)0))' from 'long double' to 'int' [-Wnarrowing]
   40 |         if (query(x0, 0) < query(x1, 1)) the_lines_are({0}, {-round(query(x0, 0))});
      |                                                              ^~~~~~~~~~~~~~~~~~~~
nicelines.cpp:40:62: warning: narrowing conversion of '- std::round(query(x0, (long double)0))' from 'long double' to 'int' [-Wnarrowing]
nicelines.cpp:41:54: warning: narrowing conversion of '(std::round(query(x1, (long double)1)) + (long double)1)' from 'long double' to 'int' [-Wnarrowing]
   41 |         else the_lines_are({0}, {round(query(x1, 1)) + 1});
      |                                  ~~~~~~~~~~~~~~~~~~~~^~~
nicelines.cpp:41:54: warning: narrowing conversion of '(std::round(query(x1, (long double)1)) + (long double)1)' from 'long double' to 'int' [-Wnarrowing]
nicelines.cpp:46:25: warning: narrowing conversion of 'std::round(slope)' from 'long double' to 'int' [-Wnarrowing]
   46 |     the_lines_are({round(slope)}, {round(other)});
      |                    ~~~~~^~~~~~~
nicelines.cpp:46:25: warning: narrowing conversion of 'std::round(slope)' from 'long double' to 'int' [-Wnarrowing]
nicelines.cpp:46:41: warning: narrowing conversion of 'std::round(other)' from 'long double' to 'int' [-Wnarrowing]
   46 |     the_lines_are({round(slope)}, {round(other)});
      |                                    ~~~~~^~~~~~~
nicelines.cpp:46:41: warning: narrowing conversion of 'std::round(other)' from 'long double' to 'int' [-Wnarrowing]
#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...