結果

問題 No.3041 非対称じゃんけん
ユーザー ArcAki
提出日時 2025-02-28 22:55:46
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1,586 ms / 2,200 ms
コード長 1,872 bytes
コンパイル時間 10,678 ms
コンパイル使用メモリ 402,040 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-02-28 22:56:13
合計ジャッジ時間 21,186 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#[allow(unused_imports)]
use std::{
    cell::RefCell, convert::{Infallible, TryFrom, TryInto as _},
    fmt::{self, Debug, Display, Formatter,},
    fs::{File},
    hash::{Hash, Hasher},
    iter::{Product, Sum},
    marker::PhantomData,
    ops::{Add, AddAssign, Sub, SubAssign, Div, DivAssign, Mul, MulAssign, Neg, },
    str::FromStr,
    sync::{atomic::{self, AtomicU32, AtomicU64}, Once},
    collections::{*},
    mem::{swap},
    cmp::{self, Reverse, Ordering, Eq, PartialEq, PartialOrd},
    thread::LocalKey,
    f64::consts::PI,
    time::Instant,
    io::{self, stdin, Read, read_to_string, BufWriter, BufReader, stdout, Write},
};
#[allow(unused_imports)]
use proconio::{input, input_interactive, marker::{*}};
#[allow(unused_imports)]
//use rand::{thread_rng, Rng, seq::SliceRandom};
#[allow(unused_imports)]
//use ac_library::{*};

#[allow(dead_code)]
const INF: i64 = 1<<60;
#[allow(dead_code)]
const MOD: i64 = 998244353;
#[allow(dead_code)]
const D: [(usize, usize); 4] = [(1, 0), (0, 1), (!0, 0), (0, !0)];

//use proconio::fastout;
//#[fastout]
fn main(){
    input!{
        n: usize, _f: usize,
        a: [usize; n],
        b: [usize; n],
        c: [usize; n],
    }
    let mut dp = vec![0u128; n+1];
    dp[0] |= 1;
    let mask1 = (1<<64)-1;
    let mask2 = !0;
    for i in 0..n{
        let mut ndp = vec![0u128; n+1];
        for j in 0..=i{
            let nex1 = dp[j]<<a[i];
            ndp[j] |= nex1&mask1;
            ndp[j+1] |= (nex1&mask2)>>64;
            let nex2 = dp[j]<<b[i];
            ndp[j] |= nex2&mask1;
            ndp[j+1] |= (nex2&mask2)>>64;
            let nex3 = dp[j]<<c[i];
            ndp[j] |= nex3&mask1;
            ndp[j+1] |= (nex3&mask2)>>64;
        }
        let mut res = 0;
        dp = ndp;
        for j in 0..=i{
            res += dp[j].count_ones();
        }
        println!("{}", res);
    }
}
0