結果

問題 No.870 無敵囲い
ユーザー pod1pod1
提出日時 2019-09-08 01:10:58
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 300 ms
コード長 1,033 bytes
コンパイル時間 969 ms
コンパイル使用メモリ 147,644 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 16:17:14
合計ジャッジ時間 1,849 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

warning: unused import: `std::cmp::max`
 --> Main.rs:3:5
  |
3 | use std::cmp::max;
  |     ^^^^^^^^^^^^^

warning: 2 warnings emitted

ソースコード

diff #

use std::vec::Vec;
use std::cmp::min;
use std::cmp::max;


fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
  let n: usize = read();
  let mut process: Vec<((usize, usize), (usize, usize))>  = Vec::new();
  let mut board: Vec<Vec<usize>> = vec![vec![0; 9]; 9];
  board[1][7] = 1;
  board[2][8] = 2;
  board[6][8] = 3;
  for _ in 0..n {
    let v: Vec<usize> = read_vec();
    process.push(((v[0] - 1, v[1] - 1), (v[2] - 1, v[3] - 1)));
  }

  for (now, next) in process {
    moving(&mut board, now, next);
  }

  if board[4][7] == 1 && board[3][7] == 2 && board[5][7]  == 3{
    println!("YES");
  } else {
    println!("NO");
  }

}


fn moving(b: &mut Vec<Vec<usize>>, now: (usize, usize), next: (usize, usize)) {

  b[next.0][next.1] =   b[now.0][now.1];
  b[now.0][now.1] = 0
}
0