結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 WA -
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 #

#define _USE_MATH_DEFINES
 
#include <iostream>
#include <iomanip>
 
#include <algorithm>
#include <cmath>
 
#include <string>
//#include <array>
#include <list>
#include <queue>
#include <vector>
#include <complex>
#include <set>
#include <map>
 
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
 
#define PII pair<int,int>
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int N;
int a[100],b[100],c[100],d[100];
int AA,BB,CC;
int ans = 0,tans;

void setP(int A,int B,int C,int D){
	AA = D-B;
	BB = A-C;
	CC = (A-C)*B+(D-B)*A;
	return;
}

int solve(){
	int ans = 0;
	int s,t,D;
	double X,Y;
	tans = 0;
	rep(i,N){
		s = (c[i]-a[i])*(a[i]*d[i]-b[i]*c[i]);
		t = CC;
		D = (d[i]-b[i])*BB-(a[i]-c[i])*AA;
		if(AA==0 && BB == 0){

		}
		else if( AA == 0){
			Y = CC/BB;
			if( (b[i] <= Y && Y <= d[i])||(d[i] <= Y && Y <= b[i]) ){
				++tans;
			}
		}else if( BB == 0){
			X = CC/AA;
			if( (a[i] <= X && X <= c[i] ) || (c[i] <= X && X <= a[i]) ){
				++tans;
			}
		}
		else if( D == 0){
			if(a[i]==c[i]){
				//x=a[i]
				Y = (CC-AA*a[i])/BB;
				if( (b[i] <= Y && d[i] <= Y) || (d[i] <= Y && Y <= b[i]) ){
					++tans;
				}
			}else if(b[i]==d[i]){
				//y=b[i]
				X = (CC-BB*b[i])/AA;
				if( (a[i] <= X && X <= c[i]) || (c[i] <= X && X <= a[i]) ){
					++tans;
				}
			}else{
				if( (d[i]-b[i] == AA && a[i]-c[i] == BB &&
					CC == (c[i]-a[i])*(a[i]*d[i]-b[i]*c[i])
					)||
					(d[i]-b[i] == -AA && a[i]-c[i] == -BB &&
					-CC == (c[i]-a[i])*(a[i]*d[i]-b[i]*c[i])
					)
				){
					++tans;
				}
			}
		}else{
			X = s*BB-(a[i]-c[i])*t;
			Y = (d[i]-b[i])*t-s*AA;
			X /= D;
			Y /= D;
			if(
				(
				(a[i] <= X && X <= c[i]) || (c[i] <= X && X <= a[i])
				)
				&&
				(
				(b[i] <= Y && Y <= d[i]) || (d[i] <= Y && Y <= b[i])
				)
				){
				++tans;
			}
		}
	}
	ans = max(ans,tans);
	return ans;
}

int main(void){
    std::cin.tie(0); 
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(10);//
	
	cin>>N;
	
	rep(i,N){
		cin>>a[i]>>b[i]>>c[i]>>d[i];
	}
	
	int ANS=0,temp;

	for(int i=0;i<N-1;++i){
		for(int j=i+1;j<N;++j){
			setP(a[i],b[i],a[j],b[j]);
			temp = solve();
			ANS = max(ANS,temp);
			
			setP(a[i],b[i],c[j],d[j]);
			temp = solve();
			ANS = max(ANS,temp);
			
			setP(c[i],d[i],a[j],b[j]);
			temp = solve();
			ANS = max(ANS,temp);
			
			setP(c[i],d[i],c[j],d[j]);
			temp = solve();
			ANS = max(ANS,temp);
		}
	}
	P(ANS);
    return 0;
}
0