結果
問題 | No.351 市松スライドパズル |
ユーザー | koba-e964 |
提出日時 | 2016-03-15 19:16:47 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 1,424 bytes |
コンパイル時間 | 10,951 ms |
コンパイル使用メモリ | 387,128 KB |
実行使用メモリ | 9,732 KB |
最終ジャッジ日時 | 2024-10-01 07:01:21 |
合計ジャッジ時間 | 13,865 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 116 ms
9,648 KB |
testcase_01 | AC | 1 ms
6,816 KB |
testcase_02 | AC | 1 ms
6,820 KB |
testcase_03 | AC | 1 ms
6,820 KB |
testcase_04 | AC | 1 ms
6,820 KB |
testcase_05 | AC | 1 ms
6,816 KB |
testcase_06 | AC | 1 ms
6,820 KB |
testcase_07 | AC | 1 ms
6,816 KB |
testcase_08 | AC | 0 ms
6,816 KB |
testcase_09 | AC | 1 ms
6,816 KB |
testcase_10 | AC | 1 ms
6,820 KB |
testcase_11 | AC | 0 ms
6,820 KB |
testcase_12 | AC | 1 ms
6,820 KB |
testcase_13 | AC | 144 ms
9,412 KB |
testcase_14 | AC | 145 ms
9,564 KB |
testcase_15 | AC | 144 ms
9,604 KB |
testcase_16 | AC | 142 ms
9,644 KB |
testcase_17 | AC | 136 ms
9,592 KB |
testcase_18 | AC | 134 ms
9,644 KB |
testcase_19 | AC | 138 ms
9,656 KB |
testcase_20 | AC | 139 ms
9,732 KB |
コンパイルメッセージ
warning: unused import: `std::cmp::*` --> src/main.rs:1:5 | 1 | use std::cmp::*; | ^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: variable does not need to be mutable --> src/main.rs:9:9 | 9 | let mut stdin = std::io::stdin(); | ----^^^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default warning: function `getline` is never used --> src/main.rs:3:4 | 3 | fn getline() -> String { | ^^^^^^^ | = note: `#[warn(dead_code)]` on by default warning: variable `stdLock` should have a snake case name --> src/main.rs:10:13 | 10 | let mut stdLock = stdin.lock(); | ^^^^^^^ help: convert the identifier to snake case: `std_lock` | = note: `#[warn(non_snake_case)]` on by default warning: unused `Result` that must be used --> src/main.rs:15:13 | 15 | stdLock.read(&mut u8b); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled = note: `#[warn(unused_must_use)]` on by default help: use `let _ = ...` to ignore the resulting value | 15 | let _ = stdLock.read(&mut u8b); | +++++++
ソースコード
use std::cmp::*; use std::io::*; fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); return ret; } fn getword() -> String { let mut stdin = std::io::stdin(); let mut stdLock = stdin.lock(); let mut u8b: [u8; 1] = [0]; loop { let mut buf: Vec<u8> = Vec::with_capacity(16); loop { stdLock.read(&mut u8b); if u8b[0] <= ' ' as u8 { break; } else { buf.push(u8b[0]); } } if buf.len() >= 1 { let ret = std::string::String::from_utf8(buf).unwrap(); return ret; } } } fn parse<T : std::str::FromStr>(s : &str) -> T { match s.parse::<T>() { Ok(t) => t, _ => panic!(), } } fn main() { let h: i32 = parse(&getword()); let w: i32 = parse(&getword()); let n: usize = parse(&getword()); let mut s = vec![' '; n]; let mut k = vec![0; n]; let mut x = 0; let mut y = 0; for i in 0 .. n { s[i] = getword().chars().next().unwrap(); k[i] = parse(&getword()); } for i in (0 .. n).rev() { match s[i] { 'R' => if y == k[i] { x = (x + w - 1) % w }, 'C' => if x == k[i] { y = (y + h - 1) % h }, _ => panic!(), }; } println!("{}", if (x + y) % 2 == 0 { "white" } else { "black" }); }