結果
問題 | No.351 市松スライドパズル |
ユーザー | cympfh |
提出日時 | 2016-04-02 13:30:47 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 168 ms / 2,000 ms |
コード長 | 1,779 bytes |
コンパイル時間 | 4,015 ms |
コンパイル使用メモリ | 168,496 KB |
実行使用メモリ | 9,584 KB |
最終ジャッジ日時 | 2023-10-25 07:44:02 |
合計ジャッジ時間 | 7,079 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 159 ms
9,584 KB |
testcase_01 | AC | 1 ms
4,348 KB |
testcase_02 | AC | 1 ms
4,348 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | AC | 1 ms
4,348 KB |
testcase_05 | AC | 1 ms
4,348 KB |
testcase_06 | AC | 1 ms
4,348 KB |
testcase_07 | AC | 1 ms
4,348 KB |
testcase_08 | AC | 1 ms
4,348 KB |
testcase_09 | AC | 1 ms
4,348 KB |
testcase_10 | AC | 1 ms
4,348 KB |
testcase_11 | AC | 0 ms
4,348 KB |
testcase_12 | AC | 1 ms
4,348 KB |
testcase_13 | AC | 162 ms
9,584 KB |
testcase_14 | AC | 164 ms
9,584 KB |
testcase_15 | AC | 168 ms
9,584 KB |
testcase_16 | AC | 166 ms
9,584 KB |
testcase_17 | AC | 161 ms
9,584 KB |
testcase_18 | AC | 161 ms
9,584 KB |
testcase_19 | AC | 165 ms
9,584 KB |
testcase_20 | AC | 166 ms
9,584 KB |
コンパイルメッセージ
warning: unused import: `Write` --> Main.rs:1:22 | 1 | use std::io::{ self, Write }; | ^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused imports: `max`, `min` --> Main.rs:3:17 | 3 | use std::cmp::{ min, max }; | ^^^ ^^^ warning: unused import: `BinaryHeap` --> Main.rs:4:25 | 4 | use std::collections::{ BinaryHeap, VecDeque }; | ^^^^^^^^^^ warning: unused macro definition: `trace` --> Main.rs:6:14 | 6 | macro_rules! trace { | ^^^^^ | = note: `#[warn(unused_macros)]` on by default warning: 4 warnings emitted
ソースコード
use std::io::{ self, Write }; use std::str::FromStr; use std::cmp::{ min, max }; use std::collections::{ BinaryHeap, VecDeque }; macro_rules! trace { ($var:expr) => ({ let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var); }) } fn main() { let mut sc = Scanner::new(); let h:i32 = sc.cin(); let w:i32 = sc.cin(); let n = sc.cin(); let mut i = 0; let mut j = 0; for &(s,k) in (0..n).map(|_| { let s = sc.get_char(); let k = sc.cin(); (s, k) }).collect::<Vec<_>>().iter().rev() { if s == 'R' { if i == k { j = (j + w - 1) % w; } } else { if j == k { i = (i + h - 1) % h; } } } println!("{}", if (i+j)%2==0 { "white" } else { "black" }); } #[allow(dead_code)] struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } } fn reserve(&mut self) { while self.buffer.len() == 0 { let mut line = String::new(); let _ = self.stdin.read_line(&mut line); for w in line.split_whitespace() { self.buffer.push_back(String::from(w)); } } } fn cin<T: FromStr>(&mut self) -> T { self.reserve(); match self.buffer.pop_front().unwrap().parse::<T>() { Ok(a) => a, Err(_) => panic!("parse err") } } fn get_char(&mut self) -> char { self.reserve(); let head = self.buffer[0].chars().nth(0).unwrap(); let tail = String::from( &self.buffer[0][1..] ); if tail.len()>0 { self.buffer[0]=tail } else { self.buffer.pop_front(); } head } }