結果

問題 No.1144 Triangles
ユーザー akakimidoriakakimidori
提出日時 2021-04-16 18:36:33
言語 Rust
(1.77.0)
結果
AC  
実行時間 111 ms / 3,000 ms
コード長 990 bytes
コンパイル時間 3,127 ms
コンパイル使用メモリ 152,604 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-15 16:28:01
合計ジャッジ時間 6,390 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 111 ms
4,380 KB
testcase_05 AC 110 ms
4,380 KB
testcase_06 AC 109 ms
4,376 KB
testcase_07 AC 109 ms
4,380 KB
testcase_08 AC 109 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 100 ms
4,376 KB
testcase_15 AC 100 ms
4,380 KB
testcase_16 AC 106 ms
4,380 KB
testcase_17 AC 106 ms
4,376 KB
testcase_18 AC 106 ms
4,380 KB
testcase_19 AC 3 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 102 ms
4,380 KB
testcase_23 AC 6 ms
4,380 KB
testcase_24 AC 101 ms
4,380 KB
testcase_25 AC 31 ms
4,384 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 14 ms
4,380 KB
testcase_28 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn read() -> Vec<(i64, i64)> {
    let mut s = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let mut next = || it.next().unwrap().parse::<i64>().unwrap();
    let n = next();
    (0..n)
        .map(|_| {
            let x = next();
            let y = next();
            (x, y)
        })
        .collect()
}

fn main() {
    let mut p = read();
    p.sort_by_key(|p| (p.1, p.0));
    const MOD: i64 = 1_000_000_007;
    let mut ans = 0;
    for i in 0..(p.len() - 2) {
        let s = p[i];
        let mut p = p[(i + 1)..]
            .iter()
            .map(|p| (p.0 - s.0, p.1 - s.1))
            .collect::<Vec<_>>();
        p.sort_by(|a, b| (a.0 * b.1).cmp(&(a.1 * b.0)));
        let mut a = 0;
        let mut b = 0;
        for &(x, y) in p.iter() {
            ans = (ans + b * x - a * y) % MOD;
            a += x;
            b += y;
        }
    }
    println!("{}", ans);
}
0