# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743147 | jamielim | 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.
#include "nice_lines.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
typedef vector<int> vi;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
void solve(int subtask_id, int N) {
if(N==1){
long double s=query(0,0);
long double t=query(0,1);
long double k=abs(s-t);
long double b=s/k;
if(abs(query(0,b))<EPS){
if(query(1,0)-s>-EPS){
// a>=0 => k>0
long double a1=-k*k + sqrt(2*k*k-1) / (k*k-1);
long double a2=-k*k - sqrt(2*k*k-1) / (k*k-1);
if(query(1,a1+b)<EPS)the_lines_are((int)round(a1),(int)round(b));
else the_lines_are((int)round(a2),(int)round(b));
}else{
// a<0 => k<0
k=-k;
long double a1=-k*k + sqrt(2*k*k-1) / (k*k-1);
long double a2=-k*k - sqrt(2*k*k-1) / (k*k-1);
if(query(1,a1+b)<EPS)the_lines_are((int)round(a1),(int)round(b));
else the_lines_are((int)round(a2),(int)round(b));
}
}else{
b=-b;
if(s-query(1,0)>-EPS){
// a>=0 => k>0
long double a1=-k*k + sqrt(2*k*k-1) / (k*k-1);
long double a2=-k*k - sqrt(2*k*k-1) / (k*k-1);
if(query(1,a1+b)<EPS)the_lines_are((int)round(a1),(int)round(b));
else the_lines_are((int)round(a2),(int)round(b));
}else{
// a<0 => k<0
k=-k;
long double a1=-k*k + sqrt(2*k*k-1) / (k*k-1);
long double a2=-k*k - sqrt(2*k*k-1) / (k*k-1);
if(query(1,a1+b)<EPS)the_lines_are((int)round(a1),(int)round(b));
else the_lines_are((int)round(a2),(int)round(b));
}
}
}
}