結果

問題 No.1041 直線大学
ユーザー 沙耶花沙耶花
提出日時 2020-05-01 21:25:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 3,322 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 201,524 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 06:42:20
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 6 ms
4,376 KB
testcase_11 AC 6 ms
4,380 KB
testcase_12 AC 9 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 4 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 4 ms
4,376 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,384 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,384 KB
testcase_35 AC 1 ms
4,384 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

const double eps = 1e-10;

template <typename T>
struct vector_2d{
	T x,y,r,d;
	
	vector_2d(T a=0.0,T b=0.0){
		x = a;
		y = b;
		fix_rd();
	}
	
	void update_x(T a,T b){
		x = a*x + b;
		fix_rd();
	}
	
	void update_x(T a){
		update_x(0.0,a);
	}
	
	void update_y(T a,T b){
		y = a*y + b;
		fix_rd();
	}
	
	void update_y(T a){
		update_y(0.0,a);
	}
	
	void update_r(T a,T b){
		r = a*r + b;
		fix_xy();
	}
	
	void update_r(T a){
		update_r(0.0,a);
	}
	
	void update_d(T a,T b){
		d = a*d + b;
		fix_xy();
	}

	void update_d(T a){
		update_d(0.0,a);
	}
	
	void fix_xy(){
		x = r * cos(d);
		y = r * sin(d);
		fix_rd();
	}
	
	void fix_rd(){
		r = hypot(x,y);
		if(r==0.0)d=0.0;
		else d = atan2(y,x);
		fix_zero();
	}
	
	void fix_zero(){
		if(abs(x)<eps)x = 0.0;
		if(abs(y)<eps)y = 0.0;
		if(abs(r)<eps)r = 0.0;
		if(abs(d)<eps)d = 0.0;
	}
	
	
	T get_dis(vector_2d<T> V){
		return hypot(x-V.x,y-V.y);
	}
	
	T angle_difference(vector_2d<T> V){
		double ret = d - V.d;
		if(ret<-acos(-1.0))ret = acos(-1.0)*2.0+ret;
		if(ret>acos(-1.0))ret=-acos(-1.0)*2.0+ret;
		return ret;
	}
	
	//中点
	vector_2d get_midpoint(vector_2d<T> V){
		V.update_x(0.5,x/2.0);
		V.update_y(0.5,y/2.0);
		return V;
	}
	
	T get_inner_product(vector_2d<T> V){
		return x*V.x+y*V.y;
	}
	
	T get_cross_product(vector_2d<T> V){
		return x*V.y-y*V.x;
	}
	
	vector_2d &operator+=(const vector_2d<T> &another){
		update_x(1,another.x);
		update_y(1,another.y);
		return (*this);
	}
	
	vector_2d &operator-=(const vector_2d<T> &another){
		update_x(1,-another.x);
		update_y(1,-another.y);
		return (*this);
	}
	
	vector_2d operator+(const vector_2d<T> &another)const{
		return (vector_2d(*this)+=another);
	}
	
	vector_2d operator-(const vector_2d<T> &another)const{
		return (vector_2d(*this)-=another);
	}
	
	void show(){
		cout<<x<<','<<y<<endl;
	}
};

//ax+by+c=0
template <typename T>
struct line{
	T a,b,c;
	line(T A,T B,T C){
		a=A,b=B,c=C;
	}
	
	line(vector_2d<T> V,T A,T B){
		a = A;
		b = B;
		c = -a*V.x - b*V.y;
	}
	
	line(vector_2d<T> V1=vector_2d<T>(),vector_2d<T> V2=vector_2d<T>()):line(V1,-(V1.y-V2.y),V1.x-V2.x){
	}

	
	void fix_abc(){
		T l = hypot(a,b);
		a/=l;b/=l;c/=l;
		T X = a;
		if(abs(X)<eps)X=b;
		if(abs(X)<eps)X=c;
		if(X<0.0){
			a*=-1;
			b*=-1;
			c*=-1;
		}
	}
	
	T get_signed_dis(vector_2d<T> V){
		return (a*V.x+b*V.y+c)/hypot(a,b);
	}
	
	T get_dis(vector_2d<T> V){
		return abs(get_signed_dis(V));
	}
	
	vector_2d<T> get_projection(vector_2d<T> P){
		line L(P,-b,a);
		return get_cross_point(L);
	}
	
	vector_2d<T> get_cross_point(line<T> L){
		vector_2d<T> ret(1e20,1e20);

		if(abs(L.a*b-a*L.b)>=eps){
			ret.update_x((L.b*c-b*L.c)/(L.a*b-a*L.b));
			ret.update_y((a*L.c-L.a*c)/(L.a*b-a*L.b));
		}

		return ret;
	}
	
	void show(){
		cout<<a<<','<<b<<','<<c<<endl;
	}
	
};

int main(){
	
	int N;
	cin>>N;
	
	vector<vector_2d<double>> V(N);
	
	for(int i=0;i<N;i++){
		double x,y;
		cin>>x>>y;
		V[i] = vector_2d<double>(x,y);
	}
	
	int ans = 0;
	
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			line<double> L(V[i],V[j]);
			int t = 0;
			for(int k=0;k<N;k++){
				if(L.get_dis(V[k])<eps)t++;
			}
			ans = max(ans,t);
		}
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}
0