結果
| 問題 | 
                            No.1338 Giant Class
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Strorkis
                         | 
                    
| 提出日時 | 2021-01-15 22:05:19 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 50 ms / 2,000 ms | 
| コード長 | 1,643 bytes | 
| コンパイル時間 | 17,762 ms | 
| コンパイル使用メモリ | 401,776 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-26 14:55:19 | 
| 合計ジャッジ時間 | 16,681 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 21 | 
ソースコード
use std::io::{Read, Write};
struct Scanner<R> { bytes: std::io::Bytes<R>, buf: Vec<u8> }
 
impl<R: Read> Scanner<R> {
    fn new(r: R) -> Scanner<R> {
        Scanner { bytes: r.bytes(), buf: Vec::new() }
    }
  
    fn next(&mut self) -> &str {
        self.buf = {
            self.bytes.by_ref().map(|b| b.unwrap())
                .skip_while(|b| b.is_ascii_whitespace())
                .take_while(|b| !b.is_ascii_whitespace())
                .collect::<Vec<_>>()
        };
        unsafe { std::str::from_utf8_unchecked(&self.buf) }
    }
}
macro_rules! scan {
    ($sc:expr, [$t:tt; $n:expr]) => (
        (0..$n).map(|_| scan!($sc, $t)).collect::<Vec<_>>()
    );
    ($sc:expr, ($($t:tt),*)) => (($(scan!($sc, $t)),*));
    ($sc:expr, Usize1) => (scan!($sc, usize) - 1);
    ($sc:expr, Bytes) => ($sc.next().bytes().collect::<Vec<_>>());
    ($sc:expr, Chars) => ($sc.next().chars().collect::<Vec<_>>());
    ($sc:expr, $t:ty) => ($sc.next().parse::<$t>().unwrap());
}
fn run<R: Read, W: Write>(mut sc: Scanner<R>, mut wr: W) {
    let (h, w, q) = scan!(sc, (usize, usize, usize));
    let mut map = std::collections::BTreeMap::new();
    let mut ans = h * w;
    for _ in 0..q {
        let (y, x) = scan!(sc, (Usize1, Usize1));
        let value = map.entry(x).or_insert(h);
        if &y < value {
            ans -= *value - y;
            *value = y;
        }
        writeln!(wr, "{}", ans).ok();
    }
}
fn main() {
    let (stdin, stdout) = (std::io::stdin(), std::io::stdout());
    let sc = Scanner::new(std::io::BufReader::new(stdin.lock()));
    let wr = std::io::BufWriter::new(stdout.lock());
    run(sc, wr);
}
            
            
            
        
            
Strorkis