結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
tkzw_21
|
| 提出日時 | 2015-07-17 23:42:38 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,324 bytes |
| コンパイル時間 | 1,352 ms |
| コンパイル使用メモリ | 173,144 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 09:41:09 |
| 合計ジャッジ時間 | 15,751 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 2 |
ソースコード
#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);
}
vector<pair<double,double>> lp;
for(int i=-150;i<=150;i++){
lp.push_back(make_pair(i,-150));
lp.push_back(make_pair(i,150));
lp.push_back(make_pair(-150,i));
lp.push_back(make_pair(150,i));
}
int ret =0;
for(int i=0;i<lp.size();i++){
for(int j=0;j<lp.size();j++){
if(i == j)continue;
int cnt =0;
P p1(lp[i].first,lp[i].second),p2(lp[j].first,lp[j].second);
L l(p1,p2);
for(int k=0;k<n;k++){
if(intersectSS(l,lines[k])){
cnt++;
}
}
ret = max(ret,cnt);
}
}
cout << ret << endl;
return 0;
}
tkzw_21