結果
| 問題 | 
                            No.245 貫け!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tkzw_21
                         | 
                    
| 提出日時 | 2015-07-18 00:00:17 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,138 bytes | 
| コンパイル時間 | 1,563 ms | 
| コンパイル使用メモリ | 168,168 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-07-08 09:47:32 | 
| 合計ジャッジ時間 | 2,315 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 8 WA * 8 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const double INF = 1e12;
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}
typedef vector<P> G;
struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};
bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &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]) < EPS; // s[1] is right of l
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
int main(void){
    int n;
    cin >> n;
    vector<L> lines;
    double a,b,c,d;
    for(int i=0;i<n;i++){
        cin >> a >>  b >> c >> d;
        P p1(a,b),p2(c,d);
        L l(p1,p2);
        lines.push_back(l);
    }
    int ret =0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
        	for(int k=0;k<2;k++){
        		for(int m=0;m<2;m++){
        			P p1(lines[i][k]),p2(lines[j][m]);
            		L l(p1,p2);
            		int cnt = 0;
            		 for(int q=0;q<n;q++){
                		if(intersectLS(l,lines[q])){
                    		cnt++;
                    	}
                    }
                    ret = max(ret,cnt);
        		}
        	}
        }
    }
    cout << ret << endl;
    return 0;
}
            
            
            
        
            
tkzw_21