結果
| 問題 |
No.245 貫け!
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-07-18 00:42:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,510 bytes |
| コンパイル時間 | 674 ms |
| コンパイル使用メモリ | 90,256 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-08 09:54:50 |
| 合計ジャッジ時間 | 1,573 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 2 WA * 14 |
ソースコード
#include <sys/time.h>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <random>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
using namespace std;
struct Point{
int x;
int y;
Point(){}
Point(int x_, int y_):x(x_),y(y_){}
};
int side(const Point& a1, const Point& a2, const Point& p){
return (a2.x - a1.x) * (p.y - a1.y) - (a2.y - a1.y) * (p.x - a1.x);
}
bool cross(const Point& a1, const Point& a2, const Point& b1, const Point& b2){
int s1 = side(a1, a2, b1) * side(a1, a2, b2);
int s2 = side(b1, b2, a1) * side(b1, b2, a2);
if(s1 <= 0 && s2 <= 0){
return true;
}
return false;
}
int main(){
int N;
cin >> N;
vector<pair<Point,Point> > line(N);
vector<Point> cand(N*2);
for(int i = 0; i < N; i++){
cin >> line[i].first.x;
cin >> line[i].first.y;
cin >> line[i].second.x;
cin >> line[i].second.y;
cand[i*2] = line[i].first;
cand[i*2+1] = line[i].second;
}
int ans = 0;
for(int i = 0; i < cand.size(); i++){
for(int j = 0; j < cand.size(); j++){
if(cand[i].x == cand[j].x && cand[i].y == cand[j].y) continue;
int cnt = 0;
for(int i = 0; i < N; i++){
if(cross(line[i].first, line[i].second, cand[i], cand[j])) cnt++;
}
ans = max(ans, cnt);
}
}
cout << ans << endl;
return 0;
}
machy