結果

問題 No.149 碁石の移動
ユーザー iwot
提出日時 2020-06-07 20:03:33
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 14,859 ms
コンパイル使用メモリ 377,748 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 21:04:00
合計ジャッジ時間 15,408 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `ab`
  --> src/main.rs:26:8
   |
26 |   let (ab, bb, c) = if ab >= c {
   |        ^^ help: if this is intentional, prefix it with an underscore: `_ab`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `bb`
  --> src/main.rs:26:12
   |
26 |   let (ab, bb, c) = if ab >= c {
   |            ^^ help: if this is intentional, prefix it with an underscore: `_bb`

warning: unused variable: `bw`
  --> src/main.rs:33:12
   |
33 |   let (aw, bw) = if bw >= d {
   |            ^^ help: if this is intentional, prefix it with an underscore: `_bw`

ソースコード

diff #

macro_rules! read {
  ($x:ident, $v:expr, $idx:expr, $type:ty) => {
    let $x:$type = $v[$idx].clone().parse().unwrap();
  };

  ( $($x:ident:$t:ty),* ) => {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    let input:Vec<String> = s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
    let mut idx:i64 = -1;
    $(
      idx += 1;
      read!($x, input, idx as usize, $t);
    )*
  };
}

fn main() {
  read!(aw:i64, ab:i64);
  read!(bw:i64, bb:i64);
  read!(c:i64, d:i64);

  let (ab, bb, c) = if ab >= c {
    (ab - c, bb + c, 0)
  } else {
    (0, bb + ab, c - ab)
  };
  let (aw, bw) = (aw - c, bw + c);

  let (aw, bw) = if bw >= d {
    (aw + d, bw - d)
  } else {
    (aw + bw, 0)
  };
  println!("{}", aw);
}
0