結果
問題 | No.245 貫け! |
ユーザー |
![]() |
提出日時 | 2020-01-02 22:28:27 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 1,744 bytes |
コンパイル時間 | 2,693 ms |
コンパイル使用メモリ | 160,964 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-22 18:22:00 |
合計ジャッジ時間 | 2,167 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 16 |
ソースコード
#include "bits/stdc++.h"using namespace std;#define int long long#define FOR(i, a, b) for(int i=(a);i<(b);i++)#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)#define REP(i, n) for(int i=0; i<(n); i++)#define RREP(i, n) for(int i=(n-1); i>=0; i--)#define ALL(a) (a).begin(),(a).end()#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()#define array2(type, x, y) array<array<type, y>, x>#define vector2(type) vector<vector<type> >#define out(...) printf(__VA_ARGS__)int dxy[] = {0, 1, 0, -1, 0};/*================================*/int N,M,L;struct Pos {int x, y;bool operator == (Pos q) {return (x == q.x) && (y == q.y);}};signed main(){#if DEBUGstd::ifstream in("input.txt");std::cin.rdbuf(in.rdbuf());#endifcin>>N;vector<pair<Pos, Pos>> L(N);REP(i,N) {cin >> L[i].first.x >> L[i].first.y >> L[i].second.x >> L[i].second.y;}int ans = 0;REP(i,2*N) REP(j,2*N){auto p1 = (i%2) ? L[i/2].first : L[i/2].second;auto p2 = (j%2) ? L[j/2].first : L[j/2].second;if (p1 == p2) continue;int a = p1.x - p2.x;int b = p1.y - p2.y;/*tc=(x1-x2)*(y3-y1)+(y1-y2)*(x1-x3)td=(x1-x2)*(y4-y1)+(y1-y2)*(x1-x4)tc*td<=0*/int cnt = 0;for (auto l : L) {auto p3 = l.first;auto p4 = l.second;int tc = a * (p3.y - p1.y) + b * (p1.x - p3.x);int td = a * (p4.y - p1.y) + b * (p1.x - p4.x);if (tc * td <= 0) cnt++;}ans = max(ans, cnt);}cout << ans << endl;return 0;}