結果
| 問題 | No.245 貫け! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-18 14:47:10 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 1,445 bytes |
| 記録 | |
| コンパイル時間 | 4,418 ms |
| コンパイル使用メモリ | 354,080 KB |
| 実行使用メモリ | 9,908 KB |
| 最終ジャッジ日時 | 2026-10-18 14:47:16 |
| 合計ジャッジ時間 | 6,059 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 7 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define pii pair <int,int>
#define F first
#define S second
#define pb push_back
#define Task "SEGMENTS"
struct P{
int x, y;
P(int _x = 0, int _y = 0): x(_x), y(_y) {}
void read(){
cin >> x >> y;
}
P operator -(const P &o){
return P(x - o.x, y - o.y);
}
};
int cross(const P &p1, const P &p2){
return p1.x * p2.y - p1.y * p2.x;
}
const int N = 107;
int n, ans;
P a[N], b[N];
vector <P> p;
bool inter(P p1, P p2, P p3, P p4){
// p1, p2: line
// p3, p4: segment
if (cross(p2 - p1, p4 - p3) == 0){
if (cross(p2 - p1, p3 - p1) == 0)
return true;
return false;
}
int sign = cross(p2 - p1, p3 - p1), sign2 = cross(p2 - p1, p4 - p1);
if ((sign > 0 && sign2 > 0) || (sign < 0 && sign2 < 0))
return false;
return true;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen(Task".inp", "r", stdin);
// freopen(Task".out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; i ++){
a[i].read(); b[i].read();
p.pb(a[i]); p.pb(b[i]);
}
for (int i = 0; i < p.size(); i ++){
for (int j = i + 1; j < p.size(); j ++){
int cnt = 0;
for (int k = 1; k <= n; k ++){
cnt += inter(p[i], p[j], a[k], b[k]);
}
ans = max(ans, cnt);
}
}
cout << ans;
}