#include<bits/stdc++.h>
#include "nice_lines.h"
using namespace std;
#define ld long double
map<int,map<int,ld>> mp;
const int V=10000;
const int X=20001;
ld get(int x,int y){
if(mp[x].find(y)!=mp[x].end()) return mp[x][y];
else return mp[x][y]=query((ld)x,(ld)y);
}
ld get_slope(int x,int y){
return get(x,y+1)-get(x,y);
}
vector<ld> d;
vector<int> ans;
void dnc(int L,int R,ld sL,ld sR){
if(abs(sR-sL)<1e-5 || L>=R) return;
for(ld x:d){
if(abs(sR-sL-x)<3e-11){
ld dif=get(X,R)-get(X,L)-(R-L)*sL;
ld idx=dif/x;
ans.push_back(R-(int)round(idx));
return;
}
}
if(L+1==R){
ans.push_back(R);
return;
}
int M=(L+R)>>1;
dnc(L,M,sL,get_slope(X,M));
dnc(M,R,get_slope(X,M),sR);
}
void solve(int subtask_id,int N){
int R=V*X+V+1,L=-R;
for(int i=0;i<=V;i++) d.push_back((ld)(2.0)/sqrtl(i*i+1));
dnc(L,R,get_slope(X,L),get_slope(X,R));
vector<int> a,b;
for(auto x:ans){
int A=round((ld)x/X);
int B=x-A*X;
a.push_back(A);
b.push_back(B);
}
the_lines_are(a,b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
736 KB |
Output is correct |
2 |
Correct |
1 ms |
732 KB |
Output is correct |
3 |
Correct |
1 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
736 KB |
Output is correct |
2 |
Correct |
1 ms |
732 KB |
Output is correct |
3 |
Correct |
1 ms |
732 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
728 KB |
Output is correct |
2 |
Correct |
1 ms |
728 KB |
Output is correct |
3 |
Correct |
1 ms |
728 KB |
Output is correct |
4 |
Correct |
1 ms |
736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
728 KB |
Output is correct |
2 |
Correct |
6 ms |
732 KB |
Output is correct |
3 |
Correct |
6 ms |
724 KB |
Output is correct |
4 |
Correct |
6 ms |
736 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
736 KB |
Output is correct |
2 |
Correct |
3 ms |
732 KB |
Output is correct |
3 |
Correct |
3 ms |
732 KB |
Output is correct |
4 |
Correct |
3 ms |
732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
728 KB |
Output is correct |
2 |
Correct |
6 ms |
732 KB |
Output is correct |
3 |
Correct |
6 ms |
724 KB |
Output is correct |
4 |
Correct |
6 ms |
736 KB |
Output is correct |
5 |
Correct |
3 ms |
736 KB |
Output is correct |
6 |
Correct |
3 ms |
732 KB |
Output is correct |
7 |
Correct |
3 ms |
732 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
7 ms |
732 KB |
Output is correct |
10 |
Correct |
8 ms |
736 KB |
Output is correct |
11 |
Correct |
9 ms |
740 KB |
Output is correct |
12 |
Correct |
7 ms |
736 KB |
Output is correct |