結果

問題 No.245 貫け!
ユーザー koyumeishikoyumeishi
提出日時 2015-07-18 02:40:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 1,463 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 75,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 18:53:10
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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++){

			for(int j=0; j<n; j++){
				if(i==j) continue;
				long long l_y = y[j] - y[i + (k?n:0)];
				long long l_x = x[j] - x[i + (k?n:0)];

				if(l_y == 0 && l_x == 0) continue;

				int cnt = 0;
				for(int h=0; h<n; h++){
					long long a = cross( l_y, l_x, y[h] - y[i + (k?n:0)], x[h] - x[i + (k?n:0)]);
					long long b = cross( l_y, l_x, y[h + n] - y[i + (k?n:0)], x[h + n] - x[i + (k?n:0)]);
					if(a*b <= 0){
						cnt++;
					}else{
						long long c = cross(y[h] - y[i + (k?n:0)], x[h] - x[i + (k?n:0)], y[h + n] - y[i + (k?n:0)], x[h + n] - x[i + (k?n:0)]);
						long long d = dot(y[h] - y[i + (k?n:0)], x[h] - x[i + (k?n:0)], y[h + n] - y[i + (k?n:0)], x[h + n] - x[i + (k?n:0)]);
						if(c == 0 && d <= 0){
							cnt++;
						}
					}
				}
				ans = max(ans, cnt);

			}
		}
	}

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