結果

問題 No.1625 三角形の質問
ユーザー akakimidoriakakimidori
提出日時 2021-07-24 02:39:13
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 2,781 bytes
コンパイル時間 2,218 ms
コンパイル使用メモリ 145,724 KB
実行使用メモリ 11,332 KB
最終ジャッジ日時 2023-09-26 08:16:14
合計ジャッジ時間 20,069 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 139 ms
4,384 KB
testcase_02 AC 5,843 ms
11,048 KB
testcase_03 AC 1,396 ms
11,332 KB
testcase_04 AC 2,851 ms
6,896 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    pub struct Scanner<'a> {
        it: std::str::SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace(),
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            self.it.next().unwrap().parse::<T>().ok().unwrap()
        }
        pub fn next_bytes(&mut self) -> Vec<u8> {
            self.it.next().unwrap().bytes().collect()
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.it.next().unwrap().chars().collect()
        }
        pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
            (0..len).map(|_| self.next()).collect()
        }
    }
}
// ---------- end scannner ----------

use std::io::Write;

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut sc = scanner::Scanner::new(&s);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    run(&mut sc, &mut out);
}

fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) {
    let n: usize = sc.next();
    let q: usize = sc.next();
    let mut p = vec![];
    for _ in 0..n {
        let a = sc.next::<i32>();
        let b = sc.next::<i32>();
        let c = sc.next::<i32>();
        let d = sc.next::<i32>();
        let e = sc.next::<i32>();
        let f = sc.next::<i32>();
        let l = a.min(c).min(e);
        let r = a.max(c).max(e);
        let c = c - a;
        let d = d - b;
        let e = e - a;
        let f = f - b;
        let s = (c as i64 * f as i64 - d as i64 * e as i64).abs();
        p.push((l as u32, r as u32, s as u64));
    }
    for _ in 0..q {
        let op: u8 = sc.next();
        if op == 1 {
            let a = sc.next::<i32>();
            let b = sc.next::<i32>();
            let c = sc.next::<i32>();
            let d = sc.next::<i32>();
            let e = sc.next::<i32>();
            let f = sc.next::<i32>();
            let l = a.min(c).min(e);
            let r = a.max(c).max(e);
            let c = c - a;
            let d = d - b;
            let e = e - a;
            let f = f - b;
            let s = (c as i64 * f as i64 - d as i64 * e as i64).abs();
            p.push((l as u32, r as u32, s as u64));
        } else {
            let x = sc.next::<u32>();
            let y = sc.next::<u32>();
            let ans = p.iter()
                .filter(|p| x <= p.0 && p.1 <= y)
                .map(|p| p.2)
                .max()
                .unwrap_or(!0);
            writeln!(out, "{}", ans as i64).ok();
        }
    }
}
0