답안 #942891

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
942891 2024-03-11T06:28:54 Z vjudge1 Nicelines (RMI20_nicelines) C++14
84.0433 / 100
48 ms 852 KB
#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()); }
};
 
const long double eps=1e-7;
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);
}
 
pair<int, int> line_from_points(pt a, pt b){
   long double slope=round((b.y-a.y)/(b.x-a.x));
   return {(int)(round(slope)), (int)(round(a.y-a.x*slope))};
}
 
void solve(int subtask_id, int N) {
   auto f=[&](long double t) -> long double {
      return query(3e4, t);
   };
   vector<int> va, vb;
   auto dnc=[&](auto self, long double l, long double r, long double fl, long double fr){
      long double mid=(l+r)/2;
      long double fmid=f(mid);
      if (abs((fl+fr)/2-fmid)<eps) return;
      if ((r-l)<1){
         long double c=(f(r+0.1)-fr-fl+f(l-0.1))/2;
         long double d=sqrtl(max<long double>(0.0, 0.1*0.1-c*c));
         int a=round(d/c);
         if (mid<-eps) a=-a;
         int b=round(mid-(3e4)*a);
         va.push_back(a);
         vb.push_back(b);
         return;
      }
      self(self, l, mid, fl, fmid);
      self(self, mid, r, fmid, fr);
      return;
   };
   long double l=-3.3e8+rand(1, 10), r=3.3e8-rand(1, 10);
   dnc(dnc, l, r, f(l), f(r));
   the_lines_are(va, vb);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 1 ms 436 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 452 KB Output is correct
2 Correct 1 ms 440 KB Output is correct
3 Correct 1 ms 440 KB Output is correct
4 Correct 1 ms 440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 2 ms 440 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
4 Correct 3 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 36 ms 688 KB Output is partially correct
2 Partially correct 33 ms 444 KB Output is partially correct
3 Partially correct 35 ms 684 KB Output is partially correct
4 Partially correct 32 ms 444 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 12 ms 440 KB Output is partially correct
2 Partially correct 16 ms 436 KB Output is partially correct
3 Partially correct 12 ms 436 KB Output is partially correct
4 Partially correct 12 ms 700 KB Output is partially correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 36 ms 688 KB Output is partially correct
2 Partially correct 33 ms 444 KB Output is partially correct
3 Partially correct 35 ms 684 KB Output is partially correct
4 Partially correct 32 ms 444 KB Output is partially correct
5 Partially correct 12 ms 440 KB Output is partially correct
6 Partially correct 16 ms 436 KB Output is partially correct
7 Partially correct 12 ms 436 KB Output is partially correct
8 Partially correct 12 ms 700 KB Output is partially correct
9 Partially correct 41 ms 696 KB Output is partially correct
10 Partially correct 48 ms 704 KB Output is partially correct
11 Partially correct 36 ms 440 KB Output is partially correct
12 Partially correct 44 ms 696 KB Output is partially correct