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;
typedef long double dd;
pair<dd, dd> busca_ternaria(dd D)
{
dd inix = (query(1.0, 0.0) <= D) ? 1 : -1; dd iniy = 0;
dd fimx = 0; dd fimy = (query(0.0, 1.0) <= D) ? 1 : -1;
while (inix < fimx)
{
dd mx1 = ((fimx - inix) / 3.0); dd mx2 = 2*mx1;
mx1 += inix; mx2 += inix;
dd my1 = D*D - mx1*mx1; dd my2 = D*D - mx2*mx2;
dd d1 = query(mx1, my1);
dd d2 = query(mx2, my2);
if (d1 == 0.0) return make_pair(mx1, my1);
if (d2 == 0.0) return make_pair(mx2, my2);
if (d1 <= d2) {fimx = mx2; fimy = my2;}
else {inix = mx1; iniy = my1;}
}
return make_pair(fimx, fimy);
}
void solve(int subtask_id, int N)
{
if (N == 1)
{
dd D = query(0.0, 0.0);
int a, b;
if (D == 0.0)
{
b = 0.0;
int ini = -1e4 - 10; int fim = 1e4 + 10;
while (ini < fim)
{
int m1 = ((fim - ini) / 3);
int m2 = 2*m1;
m1 += ini; m2 += ini;
if (fim - ini <= 2)
{
m1 = ini+1;
m2 = fim-1;
}
dd d1 = query((long double)1.0, (long double)m1);
dd d2 = query((long double)1.0, (long double)m2);
if (d1 == 0.0)
{
vector<int> respA, respB;
respA.push_back(m1); respB.push_back(b);
the_lines_are(respA, respB);
}
else if (d2 == 0.0)
{
vector<int> respA, respB;
respA.push_back(m2); respB.push_back(b);
the_lines_are(respA, respB);
}
if (d1 <= d2) fim = m2;
else if (d2 < d1) ini = m1;
}
vector<int> respA, respB;
respA.push_back(ini); respB.push_back(b);
the_lines_are(respA, respB);
}
else
{
pair<dd, dd> ponto = busca_ternaria(D);
a = (int)(-1*(ponto.first / ponto.second));
b = (int)(D*D / ponto.second);
vector<int> respA, respB;
respA.push_back(a); respB.push_back(b);
the_lines_are(respA, respB);
}
}
else
{
return;
}
}
/*int main()
{
}*/
Compilation message (stderr)
nicelines.cpp: In function 'std::pair<long double, long double> busca_ternaria(dd)':
nicelines.cpp:8:51: warning: variable 'iniy' set but not used [-Wunused-but-set-variable]
8 | dd inix = (query(1.0, 0.0) <= D) ? 1 : -1; dd iniy = 0;
| ^~~~
# | 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... |