結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2021-05-03 16:22:51 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,357 bytes |
| コンパイル時間 | 1,918 ms |
| コンパイル使用メモリ | 199,364 KB |
| 最終ジャッジ日時 | 2025-01-21 06:15:16 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 7 |
ソースコード
//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;
}
maine_honzuki