結果

問題 No.245 貫け!
ユーザー 482ET482ET
提出日時 2018-06-11 20:18:00
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,261 bytes
コンパイル時間 2,035 ms
コンパイル使用メモリ 148,800 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-13 03:13:32
合計ジャッジ時間 3,059 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define X real()
#define Y imag()
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
const double EPS=1e-9;

// 内積 dot(a,b) = |a||b|cosθ
double dot(P a, P b) {
  return (conj(a)*b).X;
}
// 外積 cross(a,b) = |a||b|sinθ
double cross(P a, P b) {
  return (conj(a)*b).Y;
}

// 点の進行方向
int ccw(P a, P b, P c) {
  b -= a;  c -= a;
  if (cross(b,c) >  EPS) return +1;  // counter clockwise
  if (cross(b,c) < -EPS) return -1;  // clockwise
  if (dot(b,c)   < -EPS) return +2;  // c--a--b on line
  if (norm(b) < norm(c)) return -2;  // a--b--c on line or a==b
  return 0;                          // a--c--b on line or a==c or b==c
}
// 直線と線分
bool isecLS(P a1, P a2, P b1, P b2) {
  return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}

int main(void){
    int max=1;
    int n;
    int a,b,c,d;
    cin>>n;
    vector<L> l(n);
    rep(i,n){
        cin>>a>>b>>c>>d;
        l[i]=L(P(a,b),P(c,d));
    }
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            int tmp=0;
            rep(k,n){
                if(isecLS(l[i].first,l[j].first,l[k].first,l[k].second)){
                    tmp++;
                }
            }
            if(max<tmp){
                max=tmp;
                //cout<<i<<" "<<j<<" "<<endl;
            }
            tmp=0;
            rep(k,n){
                if(isecLS(l[i].first,l[j].second,l[k].first,l[k].second)){
                    tmp++;
                }
            }
            if(max<tmp){
                max=tmp;
                //cout<<i<<" "<<j<<" "<<endl;
            }
            tmp=0;
            rep(k,n){
                if(isecLS(l[i].second,l[j].second,l[k].first,l[k].second)){
                    tmp++;
                }
            }
            if(max<tmp){
                max=tmp;
                //cout<<i<<" "<<j<<" "<<endl;
            }
            tmp=0;
            rep(k,n){
                if(isecLS(l[i].second,l[j].first,l[k].first,l[k].second)){
                    tmp++;
                }
            }
            if(max<tmp){
                max=tmp;
                //cout<<i<<" "<<j<<" "<<endl;
            }
        }
    }
    cout<<max<<endl;
}
0