#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-90000);
long double expectedres3 = res2+(res2-res1)*100000;
long double thing = (res3-expectedres3)/2*sqrtl(b*b+1);
//printf("%Lf thing = %d\n",thing,-10000+(int)roundl(thing));
lines.push_back({b,-90000+(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-90000);
long double expectedres3 = res2+(res2-res1)*100000;
long double thing = (res3-expectedres3)/2*sqrtl(b*b+1);
//printf("%Lf thing = %d\n",thing,-10000+(int)roundl(thing));
lines.push_back({b,-90000+(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;
if (subtask_id==4){
t1 = solvet(-1,500)+solvet2(-500,-1);
}
else{
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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
336 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
296 KB |
Output is correct |
3 |
Correct |
1 ms |
296 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
13 ms |
340 KB |
Output is partially correct |
2 |
Partially correct |
9 ms |
344 KB |
Output is partially correct |
3 |
Partially correct |
10 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
8 ms |
392 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
6 ms |
300 KB |
Output is partially correct |
2 |
Partially correct |
12 ms |
356 KB |
Output is partially correct |
3 |
Partially correct |
7 ms |
380 KB |
Output is partially correct |
4 |
Partially correct |
8 ms |
336 KB |
Output is partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
13 ms |
340 KB |
Output is partially correct |
2 |
Partially correct |
9 ms |
344 KB |
Output is partially correct |
3 |
Partially correct |
10 ms |
344 KB |
Output is partially correct |
4 |
Partially correct |
8 ms |
392 KB |
Output is partially correct |
5 |
Partially correct |
6 ms |
300 KB |
Output is partially correct |
6 |
Partially correct |
12 ms |
356 KB |
Output is partially correct |
7 |
Partially correct |
7 ms |
380 KB |
Output is partially correct |
8 |
Partially correct |
8 ms |
336 KB |
Output is partially correct |
9 |
Partially correct |
20 ms |
440 KB |
Output is partially correct |
10 |
Partially correct |
23 ms |
488 KB |
Output is partially correct |
11 |
Partially correct |
21 ms |
456 KB |
Output is partially correct |
12 |
Partially correct |
24 ms |
500 KB |
Output is partially correct |