結果

問題 No.1041 直線大学
ユーザー trineutrontrineutron
提出日時 2019-11-12 15:25:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 1,732 ms
コンパイル使用メモリ 176,464 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 14:42:22
合計ジャッジ時間 3,220 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int gcd(int x, int y) {
    if (x < 0 || y < 0) return gcd(abs(x), abs(y));
    if (x * y == 0) return x + y;
    return gcd(y, x % y);
}

int main() {
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    for (int i = 0; i < n; i++) cin >> x.at(i) >> y.at(i);
    map<pair<int, int>, int> d;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int dx = x.at(j) - x.at(i), dy = y.at(j) - y.at(i), g = gcd(dx, dy);
            dx /= g; dy /= g;
            if (dy < 0 || (dy == 0 && dx < 0)) {
                d[make_pair(-dx, -dy)]++;
            } else {
                d[make_pair(dx, dy)]++;
            }
        }
    }
    int ans = 0, p = 0;
    for (auto x : d) {
        p = max(p, x.second);
    }
    while (ans * (ans - 1) / 2 < p) ans++;
    cout << ans << endl;
}
0