結果

問題 No.1041 直線大学
ユーザー kokatsu
提出日時 2022-02-28 19:21:25
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 690 bytes
コンパイル時間 5,425 ms
コンパイル使用メモリ 217,856 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 08:13:46
合計ジャッジ時間 4,767 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/std/numeric.d(2999): Warning: cannot inline function `std.numeric.gcdImpl!uint.gcdImpl`

ソースコード

diff #

import std;

struct Fraction {
    int num, den;
}

void main() {
    int N;
    readf("%d\n", N);

    auto X = new int[](N), Y = new int[](N);
    foreach (i; 0 .. N) readf("%d %d\n", X[i], Y[i]);

    zip(X, Y).sort;

    int res;
    foreach (i; 0 .. N-1) {
        int[Fraction] list;
        foreach (j; i+1 .. N) {
            int x = X[j] - X[i], y = Y[j] - Y[i];
            if (x > 0) {
                int g = gcd(x, y.abs);
                x /= g, y /= g;
            }
            else {
                y = 1;
            }

            ++list[Fraction(y, x)];
        }

        foreach (v; list.byValue) {
            res = max(res, v+1);
        }
    }

    res.writeln;
}
0