# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
942639 | CDuong | Nicelines (RMI20_nicelines) | C++17 | 32 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |