結果

問題 No.1041 直線大学
ユーザー phsplsphspls
提出日時 2022-11-29 00:45:33
言語 Rust
(1.77.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 1,661 bytes
コンパイル時間 11,206 ms
コンパイル使用メモリ 378,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 00:19:59
合計ジャッジ時間 12,516 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

fn gcd(a: isize, b: isize) -> isize {
    if b == 0 { return a; }
    gcd(b, a%b)
}

fn lcm(a: isize, b: isize) -> isize {
    a / gcd(a, b) * b
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();
    let mut points = (0..n).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<isize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            (temp[0], temp[1])
        })
        .collect::<Vec<_>>();

    points.sort();
    let mut result = 2;
    for i in 0..n {
        let (lx, ly) = points[i];
        for j in i+1..n {
            let (rx, ry) = points[j];
            let mut cnt = 2usize;
            for k in 0..n {
                if k == i || k == j { continue; }
                let (mx, my) = points[k];
                if lx == rx {
                    if mx == lx {
                        cnt += 1;
                    }
                } else if ly == ry {
                    if my == ly {
                        cnt += 1;
                    }
                } else {
                    if lx == mx || ly == my || mx == rx  || my == ry { continue; }
                    let (dx, dy) = (rx - lx, ry - ly);
                    let (dx2, dy2) = (mx - lx, my - ly);
                    let lcmval = lcm(dx, dx2);
                    if dy * lcmval / dx == dy2 * lcmval / dx2 {
                        cnt += 1;
                    }
                }
            }
            result = result.max(cnt);
        }
    }
    println!("{}", result);
}
0