結果

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

テストケース

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

ソースコード

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;
}

// 直線と線分
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;
            if(l[i].first!=l[j].first){
                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<<" "<<max<<" "<<1<<endl;
                }
            }
            tmp=0;
            if(l[i].first!=l[j].second){
                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<<" "<<max<<" "<<2<<endl;
                }
            }
            tmp=0;
            if(l[i].second!=l[j].second){
                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<<" "<<max<<" "<<3<<endl;
                }
            }
            tmp=0;
            if(l[i].second!=l[j].first){
                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<<" "<<max<<" "<<4<<endl;
                }
            }
        }
    }
    cout<<max<<endl;
}
0