結果

問題 No.245 貫け!
ユーザー koyumeishikoyumeishi
提出日時 2015-07-18 00:07:55
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,865 bytes
コンパイル時間 748 ms
コンパイル使用メモリ 89,664 KB
実行使用メモリ 5,316 KB
最終ジャッジ日時 2023-09-22 18:35:40
合計ジャッジ時間 1,999 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

constexpr long double PI = acos(-1.0L);

long long cross(long long y, long long x, long long y_, long long x_){
	return x*y_ - y*x_;
}


long long dot(long long y, long long x, long long y_, long long x_){
	return x*x_ + y*y_;
}

int main(){
	int n;
	cin >> n;
	vector<long long> x(2*n), y(2*n);
	for(int i=0; i<n; i++){
		cin >> x[i] >> y[i] >> x[i+n] >> y[i+n];
	}

	int ans = 1;


	for(int i=0; i<n; i++){
		for(int k=0; k<2; k++){
			set<pair<long double,int>> s;
			set<int> z;

			for(int j=0; j<n; j++){
				if(i==j) continue;
				if((y[j] == y[i+(k?n:0)] && x[j] == x[i+(k?n:0)]) || 
					(y[j+n] == y[i+(k?n:0)] && x[j+n] == x[i+(k?n:0)])){
					z.insert(j);
					continue;
				}

				long double l = atan2(0.0L + y[j] - y[i+(k?n:0)], 0.0L + x[j] - x[i+(k?n:0)]);
				long double r = atan2(0.0L + y[j+n] - y[i+(k?n:0)], 0.0L + x[j+n] - x[i+(k?n:0)]);

				long long c = cross( y[j] - y[i+(k?n:0)], x[j] - x[i+(k?n:0)], y[j+n] - y[i+(k?n:0)], x[j+n] - x[i+(k?n:0)] );
				long long d = dot( y[j] - y[i+(k?n:0)], x[j] - x[i+(k?n:0)], y[j+n] - y[i+(k?n:0)], x[j+n] - x[i+(k?n:0)] );

				if(c==0 && d <= 0){
					z.insert(j);
					continue;
				}

				if(c < 0){
					swap(l,r);
				}

				s.insert({l,j});
				s.insert({r, j+n});

				s.insert({l +PI, j});
				s.insert({r +PI, j+n});

				s.insert({l +2*PI, j});
				s.insert({r +2*PI, j+n});

				s.insert({l +3*PI, j});
				s.insert({r +3*PI, j+n});

			}

			for(auto itr = s.begin(); itr != s.end(); itr++){
				if((*itr).second < n){
					z.insert((*itr).second);

				}else{
					z.erase((*itr).second - n);
				}

				ans = max(ans, (int)z.size() + 1);
			}
		}
	}

	cout << ans << endl;
	return 0;
}
0