結果

問題 No.606 カラフルタイル
ユーザー pekempeypekempey
提出日時 2017-12-06 17:49:56
言語 Rust
(1.77.0)
結果
AC  
実行時間 145 ms / 2,000 ms
コード長 1,212 bytes
コンパイル時間 3,598 ms
コンパイル使用メモリ 138,096 KB
実行使用メモリ 5,040 KB
最終ジャッジ日時 2023-08-19 09:47:39
合計ジャッジ時間 5,970 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 17 ms
4,380 KB
testcase_17 AC 144 ms
4,764 KB
testcase_18 AC 17 ms
4,376 KB
testcase_19 AC 17 ms
4,380 KB
testcase_20 AC 145 ms
4,992 KB
testcase_21 AC 18 ms
4,376 KB
testcase_22 AC 19 ms
4,380 KB
testcase_23 AC 34 ms
4,376 KB
testcase_24 AC 106 ms
4,700 KB
testcase_25 AC 139 ms
4,380 KB
testcase_26 AC 144 ms
5,040 KB
testcase_27 AC 144 ms
4,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

macro_rules! input {
  ($($x:ident : $t:ty), *) => {
    $(let $x: $t;)*
    {
      let mut s = String::new();
      std::io::stdin().read_line(&mut s).unwrap();
      let mut it = s.trim().split_whitespace();
      $($x = it.next().unwrap().parse().unwrap();)*
      assert!(it.next().is_none());
    }
  };
}

fn main() {
  input!(n: usize, k: usize, q: usize);

  let mut a: Vec<char> = Vec::new();
  let mut b: Vec<usize> = Vec::new();
  let mut c: Vec<usize> = Vec::new();

  for _ in 0..q {
    input!(tmp_a: char, tmp_b: usize, tmp_c: usize);
    a.push(tmp_a);
    b.push(tmp_b - 1);
    c.push(tmp_c - 1);
  }

  let mut cnt: Vec<i64> = vec![0; k];
  let mut used_row = vec![false; n];
  let mut used_col = vec![false; n];

  let mut left_row: i64 = n as i64;
  let mut left_col: i64 = n as i64;

  for i in (0..q).rev() {
    if a[i] == 'C' {
      if used_col[ b[i] ] { continue; }
      used_col[ b[i] ] = true;

      cnt[ c[i] ] += left_row;
      left_col -= 1;
    } else {
      if used_row[ b[i] ] { continue; }
      used_row[ b[i] ] = true;

      cnt[ c[i] ] += left_col;
      left_row -= 1;
    }
  }
  cnt[0] += left_row * left_col;

  for i in 0..k {
    println!("{}", cnt[i]);
  }
}

0