結果
| 問題 | No.245 貫け! |
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2016-04-12 18:14:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 6 ms / 5,000 ms |
| コード長 | 1,832 bytes |
| 記録 | |
| コンパイル時間 | 652 ms |
| コンパイル使用メモリ | 84,584 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 07:20:31 |
| 合計ジャッジ時間 | 1,535 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 245.cc: No.245 貫け! - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 100;
const int MAX_N2 = MAX_N * 2;
/* typedef */
typedef long long ll;
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt& pt) : x(pt.x), y(pt.y) {}
bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
Pt<T> operator-() const { return Pt<T>(-x, -y); }
Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
T dot(Pt v) const { return x * v.x + y * v.y; }
T cross(Pt v) const { return x * v.y - y * v.x; }
};
typedef Pt<int> pt;
/* global variables */
pt pts[MAX_N * 2];
/* subroutines */
/* main */
int main() {
int n;
cin >> n;
if (n == 1) {
puts("1");
return 0;
}
int n2 = n * 2;
for (int i = 0; i < n2; i++) cin >> pts[i].x >> pts[i].y;
int maxc = 0;
for (int i = 0; i < n2; i++) {
pt &pi = pts[i];
for (int j = i + 1; j < n2; j++) {
pt &pj = pts[j];
if (pi == pj) continue;
pt v = pj - pi;
int c = 0;
for (int k = 0; k < n; k++) {
pt &pk0 = pts[k * 2], &pk1 = pts[k * 2 + 1];
if (v.cross(pk0 - pi) * v.cross(pk1 - pi) <= 0) c++;
}
if (maxc < c) maxc = c;
}
}
printf("%d\n", maxc);
return 0;
}
tnakao0123