結果
| 問題 | 
                            No.245 貫け!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2015-07-18 00:39:45 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 9 ms / 5,000 ms | 
| コード長 | 1,002 bytes | 
| コンパイル時間 | 544 ms | 
| コンパイル使用メモリ | 76,260 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-08 09:53:59 | 
| 合計ジャッジ時間 | 1,183 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 16 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 scanf("%lld%lld%lld%lld",&sx,&sy,&ex,&ey);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            
            ソースコード
#include <vector>
#include <complex>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cfloat>
using namespace std;
typedef long long val_t;
typedef complex<val_t> P;
typedef vector<P> VP;
val_t cross(const P &a,const P &b){return (conj(a)*b).imag();}
val_t dot(const P &a,const P &b){return (conj(a)*b).real();}
bool intersectLS(const VP &l, const VP &s) {
	return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
		cross(l[1]-l[0], s[1]-l[0]) <= 0; // s[1] is right of l
}
int main(){
	int n;
	scanf("%d",&n);
	vector<VP> lst(n);
	for(int i=0;i<n;i++){
		long long sx,sy,ex,ey;
		scanf("%lld%lld%lld%lld",&sx,&sy,&ex,&ey);
		lst[i]={P(sx,sy),P(ex,ey)};
	}
	int R=1;
	for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
		vector<VP> x={{lst[i][0],lst[j][0]},{lst[i][1],lst[j][0]},{lst[i][0],lst[j][1]},{lst[i][1],lst[j][1]}};
		for(auto &e:x){
			if(e[0]==e[1])continue; //bah!!!
			int r=0;
			for(int k=0;k<n;k++)r+=intersectLS(e,lst[k]);
			if(R<r)R=r;
		}
	}
	printf("%d\n",R);
}