結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2022-12-31 05:23:58 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,286 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 104,840 KB |
| 最終ジャッジ日時 | 2025-02-09 22:22:16 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 9 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <sstream>
using namespace std;
template <typename T>
struct point{
T x, y;
};
//judge if line AB intersects line CD
template <typename T>
bool intersect(point<T> &a, point<T> &b, point<T> &c, point<T> &d){
bool ans = 1;
T s, t;
s = (a.x - b.x) * (c.y - a.y) - (a.y - b.y) * (c.x - a.x);
t = (a.x - b.x) * (d.y - a.y) - (a.y - b.y) * (d.x - a.x);
if (s*t > 0) ans = 0;
s = (c.x - d.x) * (a.y - c.y) - (c.y - d.y) * (a.x - c.x);
t = (c.x - d.x) * (b.y - c.y) - (c.y - d.y) * (b.x - c.x);
if (s*t > 0) ans = 0;
return ans;
}
int main(){
long long N, mx=0, M, cnt;
cin >> N;
vector<point<long long>> c(N), d(N), e(2*N);
for (int i=0; i<N; i++){
cin >> c[i].x >> c[i].y >> d[i].x >> d[i].y;
e[2*i] = c[i];
e[2*i+1] = d[i];
}
for (int i=0; i<N*2; i++){
for (int j=0; j<N*2; j++){
cnt = 0;
for (int k=0; k<N; k++){
if (intersect(e[i], e[j], c[k], d[k])) cnt++;
}
mx = max(mx, cnt);
}
}
cout << mx << endl;
return 0;
}
srjywrdnprkt