結果
| 問題 |
No.1041 直線大学
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-01 22:05:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 921 bytes |
| コンパイル時間 | 934 ms |
| コンパイル使用メモリ | 83,616 KB |
| 最終ジャッジ日時 | 2025-01-10 04:52:57 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
#include <iostream>
#include <vector>
#include <numeric>
#include <map>
void solve() {
int n;
std::cin >> n;
std::vector<std::pair<int, int>> ps(n);
for (auto& p : ps) std::cin >> p.first >> p.second;
int ans = 0;
for (int i = 0; i < n; ++i) {
std::map<std::pair<int, int>, int> cnt;
for (int j = 0; j < n; ++j) {
if (i == j) continue;
int dx = ps[i].first - ps[j].first,
dy = ps[i].second - ps[j].second;
int g = std::gcd(dx, dy);
dx /= g, dy /= g;
if (dx < 0) {
dx = -dx;
dy = -dy;
}
++cnt[std::make_pair(dx, dy)];
}
for (auto p : cnt) ans = std::max(ans, p.second + 1);
}
std::cout << ans << std::endl;
}
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
solve();
return 0;
}