Submission #2118295


Source Code Expand

#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;
}

Submission Info

Submission Time
Task E - CARtesian Coodinate
User yokozuna57
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1877 Byte
Status WA
Exec Time 6 ms
Memory 640 KB

Compile Error

./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]);
                                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 800
Status
WA × 3
AC × 1
WA × 34
Set Name Test Cases
Sample s1.txt, s2.txt, s3.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, s1.txt, s2.txt, s3.txt
Case Name Status Exec Time Memory
01.txt WA 6 ms 640 KB
02.txt WA 6 ms 640 KB
03.txt WA 6 ms 640 KB
04.txt WA 6 ms 640 KB
05.txt WA 6 ms 640 KB
06.txt WA 6 ms 640 KB
07.txt WA 6 ms 640 KB
08.txt WA 6 ms 640 KB
09.txt WA 6 ms 640 KB
10.txt WA 6 ms 640 KB
11.txt WA 6 ms 640 KB
12.txt WA 6 ms 640 KB
13.txt WA 6 ms 640 KB
14.txt WA 6 ms 640 KB
15.txt WA 6 ms 640 KB
16.txt WA 6 ms 640 KB
17.txt WA 6 ms 640 KB
18.txt WA 6 ms 640 KB
19.txt WA 6 ms 640 KB
20.txt WA 6 ms 640 KB
21.txt WA 6 ms 640 KB
22.txt WA 6 ms 640 KB
23.txt WA 6 ms 640 KB
24.txt WA 6 ms 640 KB
25.txt WA 6 ms 640 KB
26.txt WA 6 ms 640 KB
27.txt WA 5 ms 512 KB
28.txt WA 5 ms 512 KB
29.txt WA 5 ms 512 KB
30.txt WA 5 ms 512 KB
31.txt WA 5 ms 512 KB
32.txt AC 5 ms 512 KB
s1.txt WA 5 ms 512 KB
s2.txt WA 5 ms 512 KB
s3.txt WA 5 ms 512 KB