結果
| 問題 | No.245 貫け! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-01-30 14:54:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 19 ms / 5,000 ms |
| コード長 | 2,297 bytes |
| 記録 | |
| コンパイル時間 | 799 ms |
| コンパイル使用メモリ | 95,560 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-21 19:11:25 |
| 合計ジャッジ時間 | 1,688 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
class Point
{
public:
int y, x;
Point(){
y = x = 0;
}
Point(int y0, int x0){
y = y0;
x = x0;
}
Point operator+(const Point& p) const{
return Point(y + p.y, x + p.x);
}
Point operator-(const Point& p) const{
return Point(y - p.y, x - p.x);
}
Point operator*(int a) const{
return Point(y * a, x * a);
}
long long length2() const{
return y * (long long)y + x * (long long)x;
}
long long dist2(const Point& p) const{
return (y - p.y) * (long long)(y - p.y) + (x - p.x) * (long long)(x - p.x);
}
long long dot(const Point& p) const{
return y * (long long)p.y + x * (long long)p.x; // |a|*|b|*cosθ
}
long long cross(const Point& p) const{
return x * (long long)p.y - y * (long long)p.x; // |a|*|b|*sinθ
}
bool operator==(const Point& p) const{
return x == p.x && y == p.y;
}
};
bool segmentsLine(const Point& a1, const Point& a2, const Point& b1, const Point& b2)
{
long long c = (a2-a1).cross(b1-a1);
long long d = (a2-a1).cross(b2-a1);
return c == 0 || d == 0 || ((c < 0) ^ (d < 0));
}
int main()
{
int n;
cin >> n;
vector<vector<Point> > p(n, vector<Point>(2));
for(int i=0; i<n; ++i){
for(int j=0; j<2; ++j){
cin >> p[i][j].y >> p[i][j].x;
}
}
int ans = 0;
for(int i=0; i<n; ++i){
for(int j=i; j<n; ++j){
for(int k=0; k<4; ++k){
Point a = p[i][k/2];
Point b = p[j][k%2];
if(a == b)
continue;
int cnt = 0;
for(int l=0; l<n; ++l){
if(segmentsLine(a, b, p[l][0], p[l][1]))
++ cnt;
}
ans = max(ans, cnt);
}
}
}
cout << ans << endl;
return 0;
}