#include "nice_lines.h"
#include <bits/stdc++.h>
using namespace std;
map<pair<long double,long double>,long double> querymem;
long double mquery(long double x, long double y){
if (querymem.count({x,y})) return querymem[{x,y}];
return querymem[{x,y}] = query(x,y);
}
map<int,long double> memot;
long double checkthing(int a, bool side){
//printf("call c %d\n",a);
if (memot.count(a)) return memot[a];
if (true){
long double t1 = 100000;
long double res1 = mquery(t1,t1*a+10001);
long double res2 = mquery(t1,t1*a+10000);
return memot[a] = res2-res1;
}
else{
long double t1 = 100000;
long double res1 = mquery(t1,t1*a-10001);
long double res2 = mquery(t1,t1*a-10000);
return memot[a] = res2-res1;
}
}
const long double EPS = 0.000000001l;
vector<pair<int,int> > lines;
//(a,b]
int solvet(int a, int b){
if (a==b)return 0;
long double res1 = checkthing(a,true);
long double res2 = checkthing(b,true);
//printf("%Lf %Lf myres\n",res1,res2);
if (fabsl(res1-res2)<EPS) return 0;
if (a+1==b){
long double t1 = 100000;
long double res1 = mquery(t1,t1*b+10001);
long double res2 = mquery(t1,t1*b+10000);
long double res3 = mquery(t1,t1*b-10000);
long double expectedres3 = res2+(res2-res1)*20000;
long double thing = (res3-expectedres3)/2*sqrtl(b*b+1);
//printf("%Lf thing = %d\n",thing,-10000+(int)roundl(thing));
lines.push_back({b,-10000+(int)roundl(thing)});
return 1;
}
int mid = (a+b)/2;
return solvet(a,mid)+solvet(mid,b);
}
//(a,b]
int solvet2(int a, int b){
if (a==b) return 0;
long double res1 = checkthing(a,false);
long double res2 = checkthing(b,false);
//printf("%Lf %Lf myres\n",res1,res2);
if (fabsl(res1-res2)<EPS) return 0;
if (a+1==b){
long double t1 = 100000;
long double res1 = mquery(t1,t1*b+10001);
long double res2 = mquery(t1,t1*b+10000);
long double res3 = mquery(t1,t1*b-10000);
long double expectedres3 = res2+(res2-res1)*20000;
long double thing = (res3-expectedres3)/2*sqrtl(b*b+1);
//printf("%Lf thing = %d\n",thing,-10000+(int)roundl(thing));
lines.push_back({b,-10000+(int)roundl(thing)});
return 1;
}
int mid = (a+b)/2;
return solvet2(a,mid)+solvet2(mid,b);
}
void solve(int subtask_id, int N) {
int t1 = solvet(-1,10000)+solvet2(-10001,-1);
vector<int> ansa;
vector<int> ansb;
assert(t1==N);
for (auto x : lines){
ansa.push_back(x.first);
ansb.push_back(x.second);
}
the_lines_are(ansa,ansb);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
13 ms |
464 KB |
Output is partially correct |
2 |
Partially correct |
12 ms |
352 KB |
Output is partially correct |
3 |
Partially correct |
12 ms |
372 KB |
Output is partially correct |
4 |
Partially correct |
14 ms |
360 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
12 ms |
336 KB |
Output is partially correct |
2 |
Partially correct |
8 ms |
336 KB |
Output is partially correct |
3 |
Partially correct |
11 ms |
336 KB |
Output is partially correct |
4 |
Partially correct |
7 ms |
328 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
13 ms |
464 KB |
Output is partially correct |
2 |
Partially correct |
12 ms |
352 KB |
Output is partially correct |
3 |
Partially correct |
12 ms |
372 KB |
Output is partially correct |
4 |
Partially correct |
14 ms |
360 KB |
Output is partially correct |
5 |
Partially correct |
12 ms |
336 KB |
Output is partially correct |
6 |
Partially correct |
8 ms |
336 KB |
Output is partially correct |
7 |
Partially correct |
11 ms |
336 KB |
Output is partially correct |
8 |
Partially correct |
7 ms |
328 KB |
Output is partially correct |
9 |
Partially correct |
22 ms |
456 KB |
Output is partially correct |
10 |
Partially correct |
16 ms |
484 KB |
Output is partially correct |
11 |
Partially correct |
20 ms |
496 KB |
Output is partially correct |
12 |
Partially correct |
21 ms |
452 KB |
Output is partially correct |