結果

問題 No.245 貫け!
ユーザー hirokazu1020hirokazu1020
提出日時 2015-07-19 18:41:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,853 bytes
コンパイル時間 561 ms
コンパイル使用メモリ 78,600 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 19:18:45
合計ジャッジ時間 1,999 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 25 ms
4,376 KB
testcase_12 AC 68 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 68 ms
4,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())


#define INF 1e+10
#define EPS 1e-10
#define EQ(a,b) (abs(a-b)<EPS)

//誤差を考慮して足し算
double add(double a,double b){
	if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
	return a+b;
}
struct P{//2次元ベクトル
	double x,y;
	P(){}
	P(double x,double y):x(x),y(y){}
	P operator + (P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator - (P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator * (double d){
		return P(x*d,y*d);
	}
	P operator / (double d){
		return P(x/d,y/d);
	}
	double dot(P p){//内積
		return add(x*p.x,y*p.y);
	}
	double det(P p){//外積
		return add(x*p.y,-y*p.x);
	}
	bool equal(P p){
		return (x-p.x)*(x-p.x)+(y-p.y)*(y-p.y) < EPS*EPS;
	}
	double norm()const{
		return sqrt(x*x+y*y);
	}
};
//typedef pair<P,P> Line;

//線分p1-p2上に点qがあるか判定
bool on_seg(P p1,P p2,P q){
	return (p1-q).det(p2-q)==0 && (p1-q).dot(p2-q)<=0;
}
//直線p1-p2と直線q1-q2の交点
P intersection(P p1,P p2,P q1,P q2){
	return p1+(p2-p1)*( (q2-q1).det(q1-p1)/(q2-q1).det(p2-p1) );
}


int main(){
	int n;
	P p[200];
	cin>>n;
	rep(i,n*2){
		cin>>p[i].x;
		cin>>p[i].y;
	}
	int ans=0;
	rep(i,n*2)rep(j,i){
		int cnt=0;
		rep(k,n){
			P q,r,s;
			q=p[k*2];r=p[k*2+1];
			s=intersection(p[i],p[j],q,r);
			if( fabs((p[i]-p[j]).det(p[i]-q))<EPS&&fabs((p[i]-p[j]).det(p[i]-r))<EPS || on_seg(q,r,s))cnt++;
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
}
0