結果

問題 No.245 貫け!
ユーザー TawaraTawara
提出日時 2015-07-19 02:04:06
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,372 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 77,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-08 10:16:15
合計ジャッジ時間 1,214 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

typedef vector <int> VI;
typedef vector <VI> VVI;
typedef vector <string> VS;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, LL> PIL;
typedef vector <PII>VPII;
typedef vector <PIL> VPIL;


#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define sort(c) sort((c).begin(),(c).end())

#define range(i,a,b) for(int i=(a); i < (b); i++)
#define rep(i,n) range(i,0,n)

#define MAX_INT 2147483647

int cross_prod(PII a, PII b, PII pi){
	return ( (b.first - a.first) * (b.second - pi.second) 
		   - (b.second - a.second) * (b.first - pi.first) );
}
int count(PII a, PII b, VPII ep1, VPII ep2, int N){
	int num = 0;
	rep(i,N){
		if (cross_prod(a,b,ep1[i]) * cross_prod(a,b,ep2[i]) <= 0) 
			num += 1;
	}
	return num;
}
int main(){
	int N, max_num = 1;
	VPII ep1, ep2, p;
	cin >> N;
	ep1.resize(N); ep2.resize(N);
	rep(i,N){
		cin >> ep1[i].first >> ep1[i].second >> ep2[i].first >> ep2[i].second;
		p.push_back(ep1[i]);
		p.push_back(ep2[i]);
	}
	rep(i,2*N-1)
		range(j,i+1,2*N){
			if (p[i] != p[j])
				max_num = max(max_num, count(p[i],p[j],ep1,ep2,N));
		}

	cout << max_num << endl;
	return 0;
}
0