結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2020-05-02 00:10:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,737 bytes |
| コンパイル時間 | 706 ms |
| コンパイル使用メモリ | 93,968 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-16 07:58:33 |
| 合計ジャッジ時間 | 1,707 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 1041.cc: No.1041 直線大学 - 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;
/* typedef */
template <typename T>
struct Pt {
T x, y;
Pt() {}
Pt(T _x, T _y) : x(_x), y(_y) {}
Pt(const Pt<T> &pt) : x(pt.x), y(pt.y) {}
Pt<T> operator+(const Pt<T> 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<T> 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<T> v) const { return x * v.x + y * v.y; }
T cross(Pt<T> v) const { return x * v.y - y * v.x; }
bool operator==(const Pt<T> pt) const { return x == pt.x && y == pt.y; }
bool operator<(const Pt<T> &pt) const {
return x < pt.x || (x == pt.x && y < pt.y);
}
void print() { printf("(%d,%d)", x, y); }
};
typedef Pt<int> pt;
/* global variables */
pt ps[MAX_N];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d%d", &ps[i].x, &ps[i].y);
int maxc = 0;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++) {
int c = 2;
pt v(ps[j] - ps[i]);
for (int k = j + 1; k < n; k++)
if (v.cross(ps[k] - ps[j]) == 0) c++;
if (maxc < c) maxc = c;
}
printf("%d\n", maxc);
return 0;
}
tnakao0123