結果
問題 | No.606 カラフルタイル |
ユーザー |
![]() |
提出日時 | 2017-12-07 12:54:24 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 152 ms / 2,000 ms |
コード長 | 2,876 bytes |
コンパイル時間 | 12,311 ms |
コンパイル使用メモリ | 386,208 KB |
実行使用メモリ | 9,856 KB |
最終ジャッジ日時 | 2024-11-29 04:55:53 |
合計ジャッジ時間 | 14,877 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end` --> src/main.rs:46:9 | 46 | buf.trim_right().parse::<T>().ok().unwrap() | ^^^^^^^^^^ | = note: `#[warn(deprecated)]` on by default help: replace the use of the deprecated method | 46 | buf.trim_end().parse::<T>().ok().unwrap() | ~~~~~~~~ warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end` --> src/main.rs:61:22 | 61 | let mut it = buf.trim_right().split_whitespace(); | ^^^^^^^^^^ | help: replace the use of the deprecated method | 61 | let mut it = buf.trim_end().split_whitespace(); | ~~~~~~~~ warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end` --> src/main.rs:79:22 | 79 | let mut it = buf.trim_right().split_whitespace(); | ^^^^^^^^^^ | help: replace the use of the deprecated method | 79 | let mut it = buf.trim_end().split_whitespace(); | ~~~~~~~~ warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end` --> src/main.rs:98:9 | 98 | buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect() | ^^^^^^^^^^ | help: replace the use of the deprecated method | 98 | buf.trim_end().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect() | ~~~~~~~~ warning: use of deprecated method `core::str::<impl str>::trim_right`: superseded by `trim_end` --> src/main.rs:113:9 | 113 | buf.trim_right().chars().collect() | ^^^^^^^^^^ | help: replace the use of the deprecated method | 113 | buf.trim_end().chars().collect() | ~~~~~~~~
ソースコード
fn main() {let (n, k, q) = get::tuple3::<usize,usize,usize>();let qs = get::tuple3s::<String,usize,usize>(q);let mut nr = n;let mut nc = n;let mut painted_r = vec![false; n+1];let mut painted_c = vec![false; n+1];let mut table = vec![0; k+1];for (a, b, c) in qs.into_iter().rev() {match &a[..] {"R" =>{if painted_r[b] {continue}painted_r[b] = true;table[c] += nr;nc -= 1;},"C" =>{if painted_c[b] {continue}painted_c[b] = true;table[c] += nc;nr -= 1},_ => unreachable!()}}println!("{}", n*n - &table[2..].iter().cloned().sum::<usize>());for i in 2 .. k+1 {println!("{}", table[i])}}#[allow(dead_code)]mod get {use std::io::*;use std::str::*;pub fn val<T: FromStr>() -> T {let mut buf = String::new();let s = stdin();s.lock().read_line(&mut buf).ok();buf.trim_right().parse::<T>().ok().unwrap()}pub fn vals<T: FromStr>(n: usize) -> Vec<T> {let mut vec: Vec<T> = vec![];for _ in 0 .. n {vec.push(val());}vec}pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {let mut buf = String::new();let s = stdin();s.lock().read_line(&mut buf).ok();let mut it = buf.trim_right().split_whitespace();let x = it.next().unwrap().parse::<T1>().ok().unwrap();let y = it.next().unwrap().parse::<T2>().ok().unwrap();(x, y)}pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {let mut vec: Vec<(T1, T2)> = vec![];for _ in 0 .. n {vec.push(tuple());}vec}pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {let mut buf = String::new();let s = stdin();s.lock().read_line(&mut buf).ok();let mut it = buf.trim_right().split_whitespace();let x = it.next().unwrap().parse::<T1>().ok().unwrap();let y = it.next().unwrap().parse::<T2>().ok().unwrap();let z = it.next().unwrap().parse::<T3>().ok().unwrap();(x, y, z)}pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {let mut vec: Vec<(T1, T2, T3)> = vec![];for _ in 0 .. n {vec.push(tuple3());}vec}pub fn list<T: FromStr>() -> Vec<T> {let mut buf = String::new();let s = stdin();s.lock().read_line(&mut buf).ok();buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()}pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {let mut mat: Vec<Vec<T>> = vec![];for _ in 0 .. h {mat.push(list());}mat}pub fn chars() -> Vec<char> {let mut buf = String::new();let s = stdin();s.lock().read_line(&mut buf).ok();buf.trim_right().chars().collect()}}