結果
| 問題 | 
                            No.1338 Giant Class
                             | 
                    
| コンテスト | |
| ユーザー | 
                             fukafukatani
                         | 
                    
| 提出日時 | 2021-01-15 22:23:40 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 150 ms / 2,000 ms | 
| コード長 | 1,290 bytes | 
| コンパイル時間 | 11,988 ms | 
| コンパイル使用メモリ | 378,540 KB | 
| 実行使用メモリ | 7,044 KB | 
| 最終ジャッジ日時 | 2024-11-26 16:06:03 | 
| 合計ジャッジ時間 | 15,587 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 21 | 
コンパイルメッセージ
warning: unnecessary parentheses around assigned value
  --> src/main.rs:38:20
   |
38 |             ans -= (h - y);
   |                    ^     ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
38 -             ans -= (h - y);
38 +             ans -= h - y;
   |
warning: unused variable: `i`
  --> src/main.rs:23:9
   |
23 |     for i in 0..q {
   |         ^ help: if this is intentional, prefix it with an underscore: `_i`
   |
   = note: `#[warn(unused_variables)]` on by default
            
            ソースコード
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}
fn main() {
    let v = read_vec::<i64>();
    let (h, w, q) = (v[0], v[1], v[2] as usize);
    let mut queries = vec![];
    for i in 0..q {
        let v = read_vec::<i64>();
        let (y, x) = (v[0] - 1, v[1]);
        queries.push((y, x));
    }
    let mut count = HashMap::new();
    let mut ans = h * w;
    for (y, x) in queries {
        if let Some(e) = count.get_mut(&x) {
            if y < *e {
                ans -= *e - y;
                *e = y;
            }
        } else {
            count.insert(x, y);
            ans -= (h - y);
        }
        println!("{}", ans);
    }
}
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
            
            
            
        
            
fukafukatani