結果

問題 No.351 市松スライドパズル
ユーザー koba-e964koba-e964
提出日時 2016-03-15 18:56:22
言語 Rust
(1.77.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 1,374 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 187,508 KB
実行使用メモリ 9,664 KB
最終ジャッジ日時 2024-04-08 13:22:27
合計ジャッジ時間 4,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 184 ms
9,664 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 0 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 1 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 249 ms
9,528 KB
testcase_14 AC 253 ms
9,600 KB
testcase_15 AC 264 ms
9,664 KB
testcase_16 AC 257 ms
9,664 KB
testcase_17 AC 250 ms
9,664 KB
testcase_18 AC 249 ms
9,664 KB
testcase_19 AC 257 ms
9,664 KB
testcase_20 AC 254 ms
9,664 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::cmp::*`
 --> Main.rs:1:5
  |
1 | use std::cmp::*;
  |     ^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

warning: function `getline` is never used
 --> Main.rs:3:4
  |
3 | fn getline() -> String {
  |    ^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: unused `Result` that must be used
  --> Main.rs:14:13
   |
14 |             stdin.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
   |
14 |             let _ = stdin.read(&mut u8b);
   |             +++++++

warning: 3 warnings emitted

ソースコード

diff #

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();
    loop {
        let mut buf: Vec<u8> = Vec::new();
        let mut u8b: [u8; 1] = [0];
        loop {
            stdin.read(&mut u8b);
            if u8b[0] <= ' ' as u8 {
                break;
            } else {
                buf.push(u8b[0]);
            }
        }
        let ret = std::string::String::from_utf8(buf).unwrap();
        if ret.len() >= 1 {
            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().nth(0).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" });
}
0