# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
646993 | danikoynov | Nicelines (RMI20_nicelines) | C++14 | 0 ms | 0 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.
const int maxcor = 10010;
const long double eps = 1e-9;
vector < long long > cur;
long long x;
bool process(long long lf, long long rf)
{
///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);
///cout << lf << " " << rf << " " << mid << " " << d1 << " " << md << " " << d2 << endl;
long double sum = (long double)(rf - lf) / (long double)(mid - lf) * (md - d1);
if (abs(sum - (d2 - d1)) < eps)
{
///cout << "here" << endl;
return false;
}
if (mid > 0)
{
bool tf1 = process(lf, (floor)(mid));
bool tf2 = process((ceil)(mid), rf);
if (!tf1 && !tf2)
cur.push_back((round)(mid));
}
else
{
bool tf1 = process(lf, (ceil)(mid));
bool tf2 = process((floor)(mid), rf);
if (!tf1 && !tf2)
cur.push_back((round)(mid));
}
return true;
}
void solve(int subtask_id, int N)
{
///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;
for (int i = 0; i < it1.size(); i ++)
cout << it1[i] << endl;
cur.clear();
x = maxcor * 2 + 1;
process(lf, rf);
vector < long long > it2 = cur;
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);
}