結果

問題 No.509 塗りつぶしツール
ユーザー packet0
提出日時 2017-04-29 23:10:13
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 417 bytes
コンパイル時間 12,477 ms
コンパイル使用メモリ 382,460 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 19:18:32
合計ジャッジ時間 13,442 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused `Result` that must be used
 --> src/main.rs:7:5
  |
7 |     std::io::stdin().read_line(&mut line);
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = 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
  |
7 |     let _ = std::io::stdin().read_line(&mut line);
  |     +++++++

ソースコード

diff #

const HOLES: [usize; 10] = [1, 0, 0, 0, 1, 0, 1, 0, 2, 1];
const ZERO: usize = '0' as usize;

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);

    let (mut count, mut extra) = (0, 0);

    for c in line.trim().chars() {
        count += 1;
        extra += HOLES[c as usize - ZERO];
    }

    println!("{}", std::cmp::min(count + 2 * (extra + 1), 2 * count + extra + 1));
}
0