結果

問題 No.1041 直線大学
ユーザー bond_cmprogbond_cmprog
提出日時 2020-05-01 21:44:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 1,680 bytes
コンパイル時間 2,059 ms
コンパイル使用メモリ 202,120 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 08:53:35
合計ジャッジ時間 3,713 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 6 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 9 ms
4,380 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 11 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
//template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


void solve(){
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    int ma = 0;
    REP(i,N) cin >> x[i] >> y[i];
    REP(i,N) for(int j=i+1;j<N;j++){
        int dx = x[j] - x[i], dy = y[j] - y[i];
        if(dx < 0) dx *= -1, dy *= -1;
        int g = gcd(dx, dy);
        if(dx == 0) dy = 1;
        else if(dy == 0) dx = 1;
        else dx /= g, dy /= g;
        int tmp = 2;
        REP(k,N) if(k != i && j != k){
            int ddx = x[k] - x[i], ddy = y[k] - y[i];
            if(ddx < 0) ddx *= -1, ddy *= -1;
            int gg = gcd(ddx, ddy);
            if(ddx == 0) ddy = 1;
            else if(ddy == 0) ddx = 1;
            else ddx /= gg, ddy /= gg;
            if(ddx == dx && ddy == dy) tmp++;
        }
        chmax(ma, tmp);
    }
    cout << ma << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    // int T; cin >> T; REP(t,T) solve();
}
0