結果

問題 No.245 貫け!
ユーザー tkzw_21tkzw_21
提出日時 2015-07-17 23:53:26
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,138 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 153,676 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 18:31:43
合計ジャッジ時間 3,199 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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(intersectSS(l,lines[q])){
                    		cnt++;
                    	}
                    }
                    ret = max(ret,cnt);
        		}
        	}
        }
    }

    cout << ret << endl;
    return 0;
}
0