結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-03 01:52:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,717 bytes |
| コンパイル時間 | 1,707 ms |
| コンパイル使用メモリ | 176,612 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-01-02 10:51:35 |
| 合計ジャッジ時間 | 3,176 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 34 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llong long long
int gcd(int a, int b) {
if(b == 0) return 1;
if(a % b == 0) return b;
return gcd(b, a%b);
}
void putVal(int x, int y, int a1, int a2, map<tuple<int, int, int>, set<int>> &result) {
tuple<int, int, int> key = make_tuple(a1, x, y);
if(result.find(key) == result.end()) {
result[key] = set<int>();
}
result[key].insert(a2);
}
int main() {
int n;
cin >> n;
vector<pair<int , int>> coords;
rep(i, n) {
int x, y;
cin >> x >> y;
coords.push_back(make_pair(x, y));
}
//x, y, coord
map<tuple<int, int, int>, set<int>> result;
rep(i, n) {
pair<int, int> a1 = coords[i];
int a1f = a1.first;
int a1s = a1.second;
rep(j, n) {
if(i == j) continue;
pair<int, int> a2 = coords[j];
int a2f = a2.first;
int a2s = a2.second;
if(a1f < a2f) {
int x = a2f - a1f;
int y = a2s - a1s;
int gcdval = gcd(max(abs(x), abs(y)), min(abs(x), abs(y)));
putVal(x / gcdval, y / gcdval, i, j, result);
} else if(a1f == a2f) {
putVal(0, 0, i, j, result);
} else {
int x = a1f - a2f;
int y = a1s - a2s;
int gcdval = gcd(max(abs(x), abs(y)), min(abs(x), abs(y)));
putVal(x / gcdval, y / gcdval, i, j, result);
}
}
}
int maxval = 0;
for(auto a: result) {
maxval = max(maxval, (int)a.second.size() + 1);
}
cout << maxval << "\n";
}