#include <bits/stdc++.h>
using namespace std;
#include "nice_lines.h"
#define pf printf
#define pb push_back
#define maxn 10000
#define EPS 1e-5
#define dist(a,b,x,y) (ld)abs(y-a*x-b)/pow(1+a*a,0.5)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
map<ii,ld> memo;
vector<ii> know;
ld ask(ld x,ld y){
ld res;
if(x==0){
if(memo.find({(int)x,(int)y})!=memo.end())res=memo[{(int)x,(int)y}];
else res=memo[{(int)x,(int)y}]=query(x,y);
}
else res=query(x,y);
for(auto[a,b]:know)res-=dist(a,b,x,y);
return res;
}
void solve(int subtask_id,int N){
for(int i=0;i<N;++i){
int lo=-10000,hi=10000;
if(subtask_id==4)lo=-500,hi=500;
while(hi-lo>=3){
int mid1=lo+((hi-lo)/3),mid2=lo+((hi-lo)*2/3);
if(ask(0,mid1)>ask(0,mid2))lo=mid1;
else hi=mid2;
}
ld best=1e18;int res=lo;
for(int i=lo;i<=hi;++i){
ld tmp=ask(0,i);
if(tmp<best)best=tmp,res=i;
}
int b=(int)res;
lo=-10000,hi=10000;
if(subtask_id==4)lo=-500,hi=500;
while(hi-lo>=3){
int mid1=lo+((hi-lo)/3),mid2=lo+((hi-lo)*2/3);
if(ask(EPS,mid1*EPS+b)>ask(EPS,mid2*EPS+b))lo=mid1;
else hi=mid2;
}
best=1e18;res=lo;
for(int i=lo;i<=hi;++i){
ld tmp=ask(EPS,i*EPS+b);
if(tmp<best)best=tmp,res=i;
}
int a=(int)res;
know.push_back({a,b});
}
vector<int> A,B;
for(auto[a,b]:know)A.pb(a),B.pb(b);
the_lines_are(A,B);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
3 ms |
300 KB |
Output is correct |
4 |
Correct |
2 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
3 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
316 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
79 ms |
344 KB |
Output is partially correct |
2 |
Partially correct |
75 ms |
324 KB |
Output is partially correct |
3 |
Partially correct |
75 ms |
316 KB |
Output is partially correct |
4 |
Partially correct |
65 ms |
328 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
34 ms |
324 KB |
Output is partially correct |
2 |
Partially correct |
31 ms |
332 KB |
Output is partially correct |
3 |
Partially correct |
33 ms |
372 KB |
Output is partially correct |
4 |
Partially correct |
36 ms |
320 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
79 ms |
344 KB |
Output is partially correct |
2 |
Partially correct |
75 ms |
324 KB |
Output is partially correct |
3 |
Partially correct |
75 ms |
316 KB |
Output is partially correct |
4 |
Partially correct |
65 ms |
328 KB |
Output is partially correct |
5 |
Partially correct |
34 ms |
324 KB |
Output is partially correct |
6 |
Partially correct |
31 ms |
332 KB |
Output is partially correct |
7 |
Partially correct |
33 ms |
372 KB |
Output is partially correct |
8 |
Partially correct |
36 ms |
320 KB |
Output is partially correct |
9 |
Partially correct |
125 ms |
480 KB |
Output is partially correct |
10 |
Partially correct |
136 ms |
560 KB |
Output is partially correct |
11 |
Partially correct |
130 ms |
452 KB |
Output is partially correct |
12 |
Partially correct |
130 ms |
440 KB |
Output is partially correct |