結果

問題 No.245 貫け!
ユーザー tubo28tubo28
提出日時 2015-07-14 18:42:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,122 bytes
コンパイル時間 598 ms
コンパイル使用メモリ 66,092 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-22 15:42:43
合計ジャッジ時間 1,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <utility>
#include <algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)
#define PCR Point const&
#define X first
#define Y second
#define EPS (1e-10)

typedef long double Real;
typedef pair<Real,Real> Point;

Point operator - (PCR a, PCR b){
    return Point(a.X-b.X, a.Y-b.Y);
}
Real dot(PCR a, PCR b){
    return a.X * b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}
Real norm(PCR a){
    return a.X*a.X + a.Y*a.Y;
}
bool operator == (PCR a, PCR b){
    return norm(a-b) < EPS;
}
bool intersect(PCR l0, PCR l1, PCR s0, PCR s1){
    return cross(l1-l0, s0-l0)*cross(l1-l0, s1-l0) < EPS;
}

int main(){
    int n;
    cin >> n;
    Point p[110], q[110];
    Point r[220];
    rep(i,n){
        cin >> p[i].X >> p[i].Y >> q[i].X >> q[i].Y;
        r[i*2] = p[i], r[i*2+1] = q[i];
    }
    sort(r,r+n*2);
    int m = unique(r,r+n*2) - r;
    int ans = -1;
    rep(i,m)rep(j,i){
        int cnt = 0;
        rep(k,n){
            if(intersect(r[i],r[j],p[k],q[k])) cnt++;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}
0