# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1117382 | Tenis0206 | Nicelines (RMI20_nicelines) | C++11 | 155 ms | 512 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 <bits/stdc++.h>
#include "nice_lines.h"
using namespace std;
const int cmax = 1e4;
const long double eps = 1e-3;
vector<int> a, b;
long double my_query(long double A, long double B)
{
long double rez = query(A, B);
for(int i=0;i<a.size();i++)
{
long double dist = 1.0 * abs(a[i] * A - B + b[i]) / sqrt(a[i] * a[i] + 1);
rez -= dist;
}
return rez;
}
int aprox(long double val)
{
return (int)(val + 0.5);
}
void solve(int subtask_id, int n)
{
long long A = 5 * cmax;
long long B = (A + 1) * cmax + 1;
for(int i=0;i<n;i++)
{
long double dif = my_query(A, B) - my_query(A, B - 1);
long long st = -(A + 1) * cmax - 1;
long long dr = B - 1;
long double dif_B = 0;
while(st <= dr)
{
long long mij = (st + dr) >> 1LL;
long double dif_mij = my_query(A, mij) - my_query(A, mij - 1);
if(abs(dif_mij - dif) > eps)
{
dif_B = dif_mij;
B = mij;
st = mij + 1;
}
else
{
dr = mij - 1;
}
}
if(B == 0)
{
a.push_back(0);
b.push_back(B);
}
else
{
long double val_cos = 0.5 * (dif - dif_B);
int cur_a = aprox(sqrt(1 - val_cos * val_cos) / val_cos);
int cur_b = B - cur_a * A;
a.push_back(cur_a);
b.push_back(cur_b);
}
}
the_lines_are(a, b);
}
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... |