結果
問題 | No.2711 Connecting Lights |
ユーザー | Yukino DX. |
提出日時 | 2024-03-31 14:51:29 |
言語 | Rust (1.77.0) |
結果 |
AC
|
実行時間 | 270 ms / 5,000 ms |
コード長 | 5,385 bytes |
コンパイル時間 | 602 ms |
コンパイル使用メモリ | 181,844 KB |
実行使用メモリ | 6,676 KB |
最終ジャッジ日時 | 2024-03-31 14:51:35 |
合計ジャッジ時間 | 3,398 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,676 KB |
testcase_01 | AC | 1 ms
6,676 KB |
testcase_02 | AC | 1 ms
6,676 KB |
testcase_03 | AC | 1 ms
6,676 KB |
testcase_04 | AC | 0 ms
6,676 KB |
testcase_05 | AC | 2 ms
6,676 KB |
testcase_06 | AC | 1 ms
6,676 KB |
testcase_07 | AC | 1 ms
6,676 KB |
testcase_08 | AC | 3 ms
6,676 KB |
testcase_09 | AC | 145 ms
6,676 KB |
testcase_10 | AC | 85 ms
6,676 KB |
testcase_11 | AC | 153 ms
6,676 KB |
testcase_12 | AC | 36 ms
6,676 KB |
testcase_13 | AC | 41 ms
6,676 KB |
testcase_14 | AC | 4 ms
6,676 KB |
testcase_15 | AC | 24 ms
6,676 KB |
testcase_16 | AC | 3 ms
6,676 KB |
testcase_17 | AC | 3 ms
6,676 KB |
testcase_18 | AC | 6 ms
6,676 KB |
testcase_19 | AC | 121 ms
6,676 KB |
testcase_20 | AC | 45 ms
6,676 KB |
testcase_21 | AC | 3 ms
6,676 KB |
testcase_22 | AC | 2 ms
6,676 KB |
testcase_23 | AC | 1 ms
6,676 KB |
testcase_24 | AC | 83 ms
6,676 KB |
testcase_25 | AC | 111 ms
6,676 KB |
testcase_26 | AC | 245 ms
6,676 KB |
testcase_27 | AC | 193 ms
6,676 KB |
testcase_28 | AC | 270 ms
6,676 KB |
testcase_29 | AC | 181 ms
6,676 KB |
ソースコード
#![allow(unused_imports)] //use itertools::{iproduct, Itertools}; //use proconio::input; //use proconio::marker::*; use std::collections::*; fn main() { input! { n:usize, m:usize, k:usize, } let mut dp = vec![ModInt::<MOD>::new(1); 1 << n]; for _ in 0..m - 1 { let mut ndp = vec![ModInt::<MOD>::new(0); 1 << n]; for s in 0..1 << n { for t in 0..1 << n { let mut cnt = 0; for j in 0..n { if s & (1 << j) != 0 && t & (1 << j) != 0 { cnt += 1; } } if k <= cnt { ndp[t] = ndp[t] + dp[s]; } } } dp = ndp; } let mut ans = ModInt::new(0); for i in 0..1 << n { ans += dp[i]; } println!("{}", ans); } const MOD: usize = 998244353; use modint::*; mod modint { use std::fmt; use std::ops; #[derive(Copy, Clone, PartialEq, Eq)] pub struct ModInt<const MOD: usize> { pub val: usize, } impl<const MOD: usize> ModInt<MOD> { pub fn new(val: usize) -> Self { Self { val: val % MOD } } pub fn pow(mut self, mut e: usize) -> Self { let mut res = Self::new(1); while 0 < e { if e & 1 != 0 { res *= self; } self *= self; e >>= 1; } res } } impl<const MOD: usize> From<usize> for ModInt<MOD> { fn from(value: usize) -> Self { Self { val: value % MOD } } } impl<const MOD: usize> fmt::Display for ModInt<MOD> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.val) } } impl<const MOD: usize> fmt::Debug for ModInt<MOD> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.val) } } impl<const MOD: usize> ops::Neg for ModInt<MOD> { type Output = Self; fn neg(self) -> Self::Output { Self { val: (MOD - self.val) % MOD, } } } impl<const MOD: usize> ops::Add for ModInt<MOD> { type Output = Self; fn add(self, rhs: Self) -> Self::Output { Self { val: (self.val + rhs.val) % MOD, } } } impl<const MOD: usize> ops::AddAssign for ModInt<MOD> { fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; } } impl<const MOD: usize> ops::Mul for ModInt<MOD> { type Output = Self; fn mul(self, rhs: Self) -> Self::Output { Self { val: self.val * rhs.val % MOD, } } } impl<const MOD: usize> ops::MulAssign for ModInt<MOD> { fn mul_assign(&mut self, rhs: Self) { *self = *self * rhs; } } impl<const MOD: usize> ops::Sub for ModInt<MOD> { type Output = Self; fn sub(mut self, rhs: Self) -> Self::Output { if self.val < rhs.val { self.val += MOD; } Self { val: (self.val - rhs.val) % MOD, } } } impl<const MOD: usize> ops::SubAssign for ModInt<MOD> { fn sub_assign(&mut self, rhs: Self) { if self.val < rhs.val { self.val += MOD; } *self = *self - rhs; } } impl<const MOD: usize> ops::Div for ModInt<MOD> { type Output = Self; fn div(self, rhs: Self) -> Self { assert!(rhs.val != 0); self * rhs.pow(MOD - 2) } } impl<const MOD: usize> ops::DivAssign for ModInt<MOD> { fn div_assign(&mut self, rhs: Self) { *self = *self / rhs } } } use input::*; mod input { #[macro_export] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} }; ($($r:tt)*) => { let s = { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s }; let mut iter = s.split_whitespace(); input_inner!{iter, $($r)*} }; } #[macro_export] macro_rules! input_inner { ($iter:expr) => {}; ($iter:expr, ) => {}; ($iter:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($iter, $t); input_inner!{$iter $($r)*} }; } #[macro_export] macro_rules! read_value { ($iter:expr, ( $($t:tt),* )) => { ( $(read_value!($iter, $t)),* ) }; ($iter:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>() }; ($iter:expr, chars) => { read_value!($iter, String).chars().collect::<Vec<char>>() }; ($iter:expr, usize1) => { read_value!($iter, usize) - 1 }; ($iter:expr, $t:ty) => { $iter.next().unwrap().parse::<$t>().expect("Parse error") }; } }