結果
| 問題 | 
                            No.1338 Giant Class
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ikd
                         | 
                    
| 提出日時 | 2021-01-15 22:18:53 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 150 ms / 2,000 ms | 
| コード長 | 2,166 bytes | 
| コンパイル時間 | 12,526 ms | 
| コンパイル使用メモリ | 401,260 KB | 
| 実行使用メモリ | 5,452 KB | 
| 最終ジャッジ日時 | 2024-11-26 15:55:08 | 
| 合計ジャッジ時間 | 15,696 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 21 | 
ソースコード
fn main() {
    let stdin = std::io::stdin();
    let mut rd = ProconReader::new(stdin.lock());
    let h: u64 = rd.get();
    let w: u64 = rd.get();
    let q: usize = rd.get();
    let mut ans = h * w;
    use std::collections::HashMap;
    let mut min = HashMap::new();
    for _ in 0..q {
        let y: u64 = rd.get();
        let x: u64 = rd.get();
        let yy = min.entry(x).or_insert(h + 1);
        if y < *yy {
            ans += h - (*yy - 1);
            ans -= h - (y - 1);
            *yy = y;
        }
        println!("{}", ans);
    }
}
pub struct ProconReader<R> {
    r: R,
    line: String,
    i: usize,
}
impl<R: std::io::BufRead> ProconReader<R> {
    pub fn new(reader: R) -> Self {
        Self {
            r: reader,
            line: String::new(),
            i: 0,
        }
    }
    pub fn get<T>(&mut self) -> T
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        self.skip_blanks();
        assert!(self.i < self.line.len());
        assert_ne!(&self.line[self.i..=self.i], " ");
        let line = &self.line[self.i..];
        let end = line.find(' ').unwrap_or_else(|| line.len());
        let s = &line[..end];
        self.i += end;
        s.parse()
            .unwrap_or_else(|_| panic!("parse error `{}`", self.line))
    }
    fn skip_blanks(&mut self) {
        loop {
            let start = self.line[self.i..].find(|ch| ch != ' ');
            match start {
                Some(j) => {
                    self.i += j;
                    break;
                }
                None => {
                    self.line.clear();
                    self.i = 0;
                    let num_bytes = self.r.read_line(&mut self.line).unwrap();
                    assert!(num_bytes > 0, "reached EOF :(");
                    self.line = self.line.trim_end_matches(&['\r', '\n'][..]).to_string();
                }
            }
        }
    }
    pub fn get_vec<T>(&mut self, n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
        <T as std::str::FromStr>::Err: std::fmt::Debug,
    {
        (0..n).map(|_| self.get()).collect()
    }
}
            
            
            
        
            
ikd