結果

問題 No.727 仲介人moko
コンテスト
ユーザー 特命ログイン
提出日時 2018-08-25 04:53:09
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
WA  
実行時間 -
コード長 989 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 989 ms
コンパイル使用メモリ 208,668 KB
実行使用メモリ 18,832 KB
最終ジャッジ日時 2026-03-09 06:38:59
合計ジャッジ時間 34,166 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2 TLE * 1
other WA * 10 TLE * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
  --> src/main.rs:22:21
   |
22 |                 let mut e = t.entry((p - 1, b)).or_insert(0);
   |                     ----^
   |                     |
   |                     help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` (part of `#[warn(unused)]`) on by default

warning: variable does not need to be mutable
  --> src/main.rs:27:21
   |
27 |                 let mut e = t.entry((p, b - 1)).or_insert(0);
   |                     ----^
   |                     |
   |                     help: remove this `mut`

ソースコード

diff #
raw source code

use std::io::{Read, stdin};
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    stdin().read_to_string(&mut buf).unwrap();
    let mut tok = buf.split_whitespace();
    let mut get = || tok.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    let m = 1000000007;
    let n = get!();
    
    let mut h = HashMap::new();
    h.insert((n, n), 1);
    for _ in 0..2*n {
        let mut t = HashMap::new();
        for (&(p, b), c) in h.iter() {
            if p > 0 {
                let mut e = t.entry((p - 1, b)).or_insert(0);
                let c = *e + (c * p) % m;
                *e = c % m;
            }
            if p != b {
                let mut e = t.entry((p, b - 1)).or_insert(0);
                let c = *e + (c * b % m); // * (2 * n - p - b)  % m;
                *e = c % m;
            }
        }
        h = t;
    }
    println!("{}", h.get(&(0,0)).unwrap());
}
0