結果

問題 No.671 1000000007
ユーザー lzy9lzy9
提出日時 2018-04-13 22:32:11
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 681 bytes
コンパイル時間 3,336 ms
コンパイル使用メモリ 147,776 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 04:39:37
合計ジャッジ時間 4,234 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

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

warning: unused import: `std::mem::swap`
 --> Main.rs:4:5
  |
4 | use std::mem::swap;
  |     ^^^^^^^^^^^^^^

warning: unused import: `std::collections::HashMap`
 --> Main.rs:5:5
  |
5 | use std::collections::HashMap;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^

warning: static `DX` is never used
  --> Main.rs:19:8
   |
19 | static DX: &'static [i32] = &[0, 0, 1, -1];
   |        ^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: static `DY` is never used
  --> Main.rs:20:8
   |
20 | static DY: &'static [i32] = &[1, -1, 0, 0];
   |        ^^

warning: 5 warnings emitted

ソースコード

diff #

use std::io::*;
use std::str::FromStr;
use std::cmp::{min, max};
use std::mem::swap;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin_lock = stdin.lock();
    let s = stdin_lock
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}

static DX: &'static [i32] = &[0, 0, 1, -1];
static DY: &'static [i32] = &[1, -1, 0, 0];

fn main() {
    let n: String = read();

    let zero_count = n.chars().filter(|c| *c == '0').count() as i32;

    println!("{}", (zero_count - 8).abs());
}
0