This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
____ ____ ____ ____ ____ ____
||l |||e |||i |||n |||a |||d ||
||__|||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|/__\|
**/
#include<bits/stdc++.h>
#define endl '\n'
#include "nice_lines.h"
using namespace std;
typedef long long ll;
int maxcor = 1e4 + 10;
const long double eps = 1e-9;
vector < long long > cur;
long long x;
void process(long long lf, long long rf)
{
if (rf - lf <= 1)
return;
///cout << lf << " :: " << rf << endl;
long double d1 = query(x, lf), d2 = query(x, rf);
long long mid = (lf + rf) / 2;
long double md = query(x, mid);
long double sum = (long double)(rf - lf) / (long double)(mid - lf) * (md - d1);
///cout << lf << " " << rf << " " << mid << " " << d1 << " " << md << " " << d2 << " " << sum << endl;
if (abs(sum - (d2 - d1)) < eps)
{
///cout << "here" << endl;
return;
}
if ((query(x, mid - 1) - md) - (md - query(x, mid + 1)) > eps)
cur.push_back((round)(mid));
if (mid > 0)
{
process(lf, (floor)(mid));
process((ceil)(mid), rf);
}
else
{
process(lf, (ceil)(mid));
process((floor)(mid), rf);
}
}
void solve(int subtask_id, int N)
{
if (N > 3)
maxcor = 510;
///cout << (ceil)(2.0) << endl;
cur.clear();
x = maxcor * 2;
long long lf = -maxcor * maxcor, rf = maxcor * maxcor;
process(lf, rf);
vector < long long > it1 = cur;
cur.clear();
x = maxcor * 2 + 1;
process(lf, rf);
vector < long long > it2 = cur;
sort(it1.begin(), it1.end());
sort(it2.begin(), it2.end());
vector < int > a, b;
for (int i = 0; i < it1.size(); i ++)
{
///cout << it2[i] << " " << it1[i] << endl;
a.push_back((round)(it2[i] - it1[i]));
b.push_back((round)(it2[i] - x * (it2[i] - it1[i])));
}
the_lines_are(a, b);
}
Compilation message (stderr)
nicelines.cpp: In function 'void solve(int, int)':
nicelines.cpp:75:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | for (int i = 0; i < it1.size(); i ++)
| ~~^~~~~~~~~~~~
# | 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... |