結果

問題 No.245 貫け!
ユーザー maine_honzukimaine_honzuki
提出日時 2021-05-03 16:22:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,357 bytes
コンパイル時間 3,573 ms
コンパイル使用メモリ 205,488 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-29 12:33:26
合計ジャッジ時間 2,883 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//https://ncode.syosetu.com/n4830bu/245/
#include <bits/stdc++.h>
using namespace std;

using Real = double;
using Point = complex<Real>;
#define x real()
#define y imag()
const Real EPS = 1e-8, PI = acos(-1);

Real cross(const Point& a, const Point& b) {
    return a.x * b.y - a.y * b.x;
}

struct Line {
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {}
};
struct Segment : Line {
    Segment(Point a, Point b) : Line(a, b) {}
};

bool intersect(const Line& l, const Segment& s) {
    return cross(l.b - l.a, s.a - l.a) * cross(l.b - l.a, s.b - l.b) < EPS;
}

int main() {
    int N;
    cin >> N;
    vector<Segment> segments;
    for (int i = 0; i < N; i++) {
        Real a, b, c, d;
        cin >> a >> b >> c >> d;
        segments.push_back({{a, b}, {c, d}});
    }
    vector<Line> lines;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < i; j++) {
            lines.push_back({segments[i].a, segments[j].a});
            lines.push_back({segments[i].a, segments[j].b});
            lines.push_back({segments[i].b, segments[j].a});
            lines.push_back({segments[i].b, segments[j].b});
        }
    }
    int ans = 1;
    for (auto&& l : lines) {
        int maine = 0;
        for (auto&& s : segments) {
            maine += intersect(l, s);
        }
        ans = max(ans, maine);
    }
    cout << ans << endl;
}
0