結果

問題 No.2561 みんな大好きmod 998
ユーザー neko_the_shadowneko_the_shadow
提出日時 2024-02-16 15:15:51
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 180,200 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-02-16 15:15:59
合計ジャッジ時間 6,871 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 14 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 371 ms
6,676 KB
testcase_04 AC 362 ms
6,676 KB
testcase_05 WA -
testcase_06 AC 364 ms
6,676 KB
testcase_07 AC 1 ms
6,676 KB
testcase_08 AC 1 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 1 ms
6,676 KB
testcase_11 AC 53 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 1 ms
6,676 KB
testcase_14 AC 1 ms
6,676 KB
testcase_15 AC 362 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 1 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 255 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 1 ms
6,676 KB
testcase_25 AC 1 ms
6,676 KB
testcase_26 AC 72 ms
6,676 KB
testcase_27 AC 380 ms
6,676 KB
testcase_28 AC 100 ms
6,676 KB
testcase_29 AC 27 ms
6,676 KB
testcase_30 AC 82 ms
6,676 KB
testcase_31 AC 177 ms
6,676 KB
testcase_32 AC 42 ms
6,676 KB
testcase_33 AC 27 ms
6,676 KB
testcase_34 AC 362 ms
6,676 KB
testcase_35 AC 26 ms
6,676 KB
testcase_36 AC 26 ms
6,676 KB
testcase_37 AC 12 ms
6,676 KB
testcase_38 AC 52 ms
6,676 KB
testcase_39 AC 88 ms
6,676 KB
testcase_40 AC 83 ms
6,676 KB
testcase_41 AC 54 ms
6,676 KB
testcase_42 AC 100 ms
6,676 KB
testcase_43 AC 12 ms
6,676 KB
testcase_44 AC 38 ms
6,676 KB
testcase_45 AC 256 ms
6,676 KB
testcase_46 AC 33 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::stdin;

fn main() {
    let nk = read();
    let n = nk[0];
    let k = nk[1];
    let a = read();

    // bit, cur, tot
    let mut c = 0;
    let mut stack = (0..n).map(|i| (1i128 << i, i, 1)).collect::<Vec<_>>();
    while !stack.is_empty() {
        let (bit, cur, tot) = stack.pop().unwrap();
        if tot == k {
            let mut t1 = 0;
            let mut t2 = 0;
            for i in 0..n {
                if bit & (1 << i) != 0 {
                    t1 = (t1 + a[i]) % 998;
                    t2 = (t2 + a[i]) % 998244352;
                }
            }
            if t2 <= t1 {
                c = (c + 1) % 998;
            }
            continue;
        }
        for nxt in cur + 1..n {
            stack.push((bit | (1 << nxt), nxt, tot + 1));
        }
    }
    println!("{}", c);
}

fn read() -> Vec<usize> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.split_whitespace()
        .map(|token| token.parse().unwrap())
        .collect::<Vec<_>>()
}
0