結果

問題 No.1041 直線大学
ユーザー mdstoymdstoy
提出日時 2020-05-01 21:39:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 2,437 bytes
コンパイル時間 2,709 ms
コンパイル使用メモリ 195,832 KB
最終ジャッジ日時 2025-01-10 04:26:57
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<pair<double, double>> p(n);
    int x, y;
    REP(i, n) {
        cin >> x >> y;
        p[i] = make_pair(x, y);
    }

    int ans = 0;
    REP(i, n - 1) FOR(j, i + 1, n) {
        int t = 2;
        if (p[j].second == p[i].second) {
            REP(k, n) {
                if (k == i or k == j) continue;
                if (p[k].second == p[i].second) t++;
            }
        } else if (p[j].first == p[i].first) {
            REP(k, n) {
                if (k == i or k == j) continue;
                if (p[k].first == p[i].first) t++;
            }

        } else {
            double a = (p[j].second - p[i].second) / (p[j].first - p[i].first);
            double b = p[i].second - (a * p[i].first);
            REP(k, n) {
                if (k == i or k == j) continue;
                if (p[k].first * a + b == p[k].second) t++;
            }
        }
        chmax(ans, t);
        // cout << i << ":" << j << ": " << t << "/ " << ans << endl;
    }
    cout << ans << endl;
}
0