이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "nice_lines.h"
#include <bits/stdc++.h>
using namespace std;
template<class T>
struct Point{
T x, y;
Point (T _x=0, T _y=0){
x=_x; y=_y;
}
bool operator<(Point a){ return tie(x, y)<tie(a.x, a.y); }
bool operator==(Point a){ return tie(x, y)==tie(a.x, a.y); }
Point operator+(Point a){ return Point(x+a.x, y+a.y); }
Point operator-(Point a){ return Point(x-a.x, y-a.y); }
Point operator*(T a){ return Point(x*a, y*a); }
Point operator/(T a){ return Point(x/a, y/a); }
T dot(Point a){ return x*a.x+y*a.y; }
T dot(Point a, Point b){ return (a-*this).dot(b-*this); }
T cross(Point a){ return x*a.y-y*a.x; }
T cross(Point a, Point b){ return (a-*this).cross(b-*this); }
T dist2(){ return x*x+y*y; }
long double dist(){ return sqrt(dist2()); }
};
using pt=Point<long double>;
long double line_point_dist(pt a, pt b, pt c){
return abs(a.cross(b, c))/(a-b).dist();
}
mt19937 rng(69420);
long double rand(long double l, long double r){
return uniform_real_distribution<long double>(l, r)(rng);
}
void solve(int subtask_id, int N) {
if (N==1){
pt a, b;
{
pt l(-1e12, -rand(0, 69420));
pt r(1e12, rand(0, 69420));
for (int i=0; i<1000; ++i){
pt m1=l+(r-l)/3, m2=l+(r-l)/3*2;
long double t1=query(m1.x, m1.y), t2=query(m2.x, m2.y);
if (t1<t2) r=m2;
else l=m1;
}
a=l;
}
{
pt l(-rand(0, 69420), -1e12);
pt r(rand(0, 69420), 1e12);
for (int i=0; i<1000; ++i){
pt m1=l+(r-l)/3, m2=l+(r-l)/3*2;
long double t1=query(m1.x, m1.y), t2=query(m2.x, m2.y);
if (t1<t2) r=m2;
else l=m1;
}
b=l;
}
long double slope=round((b.y-a.y)/(b.x-a.x));
cerr << fixed << setprecision(6) << a.x << ' ' << a.y << ' ' << b.x << ' ' << b.y << endl;
the_lines_are({(int)(round(slope))}, {(int)(round(a.y-a.x*slope))});
return;
}
}
# | 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... |