#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define pb push_back
#define fr first
#define sc second
const long double EPS = 0.00000000001;
struct BIT{
int siz;
int a[(1<<16)+10];
void init(int siz_ = 1<<16){
siz = siz_;
for(int i = 1 ; i <= siz ; i ++){
a[i] = 0;
}
}
void add(int k,int x = 1){
while(k <= siz){
a[k] += x;
k += k&-k;
}
}
int sum(int k){
int ret = 0;
while(k > 0){
ret += a[k];
k -= k&-k;
}
return ret;
}
}bit;
int N;
long double A[4002];
long double B[4002];
long double C[4002];
ll inv(vector<pair<long double,long double>> *vec){
/*for(int i = 0 ; i < vec->size() ; i ++){
cout << (*vec)[i].fr << " " << (*vec)[i].sc << endl;
}*/
vector<pair<long double,int>> a;
for(int i = 0 ; i < vec->size() ; i ++){
a.pb(pair<long double,int>((*vec)[i].sc,i+1));
}
sort(a.begin(),a.end());
int ret = 0;
bit.init();
for(int i = 0 ; i < a.size() ; i ++){
ret += bit.sum(a[i].sc);
bit.add(a[i].sc);
}
return N*(N-1)/2-ret;
}
long double sol(){
long double l = -100000000.0 , r = 100000000.0;
while(l+EPS < r){
long double m = (l+r)/2.0;
vector<pair<long double,long double>> vec;
for(int i = 1 ; i <= N ; i ++){
vec.pb(pair<long double,long double>((C[i]-A[i]*m)/B[i],-A[i]/B[i]));
}
sort(vec.begin(),vec.end());
if(inv(&vec)*4 <= N*(N-1))r = m;
else l = m;
}
return l;
}
int main(){
cout.precision(20);
scanf("%d",&N);
for(int i = 1 ; i <= N ; i ++){
scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
}
long double X = sol();
for(int i = 1 ; i <= N ; i ++){
swap(A[i],B[i]);
}
long double Y = sol();
cout << X << " " << Y << endl;
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:88:38: warning: format ‘%lf’ expects argument of type ‘double*’, but argument 2 has type ‘long double*’ [-Wformat=]
scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
^
./Main.cpp:88:38: warning: format ‘%lf’ expects argument of type ‘double*’, but argument 3 has type ‘long double*’ [-Wformat=]
./Main.cpp:88:38: warning: format ‘%lf’ expects argument of type ‘double*’, but argument 4 has type ‘long double*’ [-Wformat=]
./Main.cpp:86:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&N);
^
./Main.cpp:88:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
^