結果
問題 | No.1238 選抜クラス |
ユーザー | o2c |
提出日時 | 2020-09-26 13:16:53 |
言語 | Rust (1.77.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,037 bytes |
コンパイル時間 | 25,587 ms |
コンパイル使用メモリ | 379,012 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-29 00:13:14 |
合計ジャッジ時間 | 16,928 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | WA | - |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 4 ms
5,376 KB |
testcase_18 | AC | 4 ms
5,376 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 4 ms
5,376 KB |
testcase_24 | AC | 4 ms
5,376 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 3 ms
5,376 KB |
testcase_32 | AC | 3 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | WA | - |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 1 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | WA | - |
ソースコード
#![allow(unused_imports)] use {std::cmp::*, std::collections::*, std::io::Write, std::ops::*}; #[allow(unused_macros)] macro_rules !dbg {($($e :expr ) ,*) =>{#[cfg (debug_assertions ) ] $({let (e ,mut err ) =(stringify !($e ) ,std ::io ::stderr () ) ;writeln !(err ,"{} = {:?}" ,e ,$e ) .unwrap () } ) *} ;} #[allow(unused_macros)] macro_rules !min {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::min ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::min ($a ,min !($($rest ) ,+) ) } } ;} #[allow(unused_macros)] macro_rules !chmin {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_min =min !($($cmps ) ,+) ;if $base >cmp_min {$base =cmp_min ;true } else {false } } } ;} #[allow(unused_macros)] macro_rules !max {($a :expr $(,) *) =>{{$a } } ;($a :expr ,$b :expr $(,) *) =>{{std ::cmp ::max ($a ,$b ) } } ;($a :expr ,$($rest :expr ) ,+$(,) *) =>{{std ::cmp ::max ($a ,max !($($rest ) ,+) ) } } ;} #[allow(unused_macros)] macro_rules !chmax {($base :expr ,$($cmps :expr ) ,+$(,) *) =>{{let cmp_max =max !($($cmps ) ,+) ;if $base <cmp_max {$base =cmp_max ;true } else {false } } } ;} #[allow(dead_code)] mod scanner { use std; use std::io::Read; use std::str::FromStr; use std::str::SplitWhitespace; pub struct Scanner<'a> { it: SplitWhitespace<'a>, } impl<'a> Scanner<'a> { pub fn new(s: &'a String) -> Scanner<'a> { Scanner { it: s.split_whitespace(), } } pub fn next<T: FromStr>(&mut self) -> T { match self.it.next().unwrap().parse::<T>() { Ok(v) => v, _ => panic!("Scanner error"), } } pub fn next_chars(&mut self) -> Vec<char> { self.next::<String>().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } pub fn read_string() -> String { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s } } const MOD: i64 = 1000000007; #[derive(Copy, Clone)] pub struct Mint(i64); impl Mint { fn new(x: i64) -> Self { Mint(x.rem_euclid(MOD)) } fn pow(self, n: usize) -> Self { match n { 0 => Mint::new(1), _ => { let mut a = self.pow(n >> 1); a *= a; if n & 1 == 1 { a *= self; } a } } } fn inv(self) -> Self { self.pow((MOD - 2) as usize) } } impl std::ops::Neg for Mint { type Output = Mint; fn neg(self) -> Self::Output { Self::new(-self.0) } } impl std::ops::AddAssign<Mint> for Mint { fn add_assign(&mut self, rhs: Self) { self.0 += rhs.0; self.0 %= MOD; } } impl std::ops::AddAssign<i64> for Mint { fn add_assign(&mut self, rhs: i64) { *self += Mint::new(rhs); } } impl<T> std::ops::Add<T> for Mint where Mint: std::ops::AddAssign<T>, { type Output = Self; fn add(self, other: T) -> Self { let mut res = self; res += other; res } } impl std::ops::SubAssign<Mint> for Mint { fn sub_assign(&mut self, rhs: Self) { self.0 -= rhs.0; if self.0 < 0 { self.0 += MOD; } } } impl std::ops::SubAssign<i64> for Mint { fn sub_assign(&mut self, rhs: i64) { *self -= Mint::new(rhs); } } impl<T> std::ops::Sub<T> for Mint where Mint: std::ops::SubAssign<T>, { type Output = Self; fn sub(self, other: T) -> Self { let mut res = self; res -= other; res } } impl std::ops::MulAssign<Mint> for Mint { fn mul_assign(&mut self, rhs: Self) { self.0 *= rhs.0; self.0 %= MOD; } } impl std::ops::MulAssign<i64> for Mint { fn mul_assign(&mut self, rhs: i64) { *self *= Mint::new(rhs); } } impl<T> std::ops::Mul<T> for Mint where Mint: std::ops::MulAssign<T>, { type Output = Self; fn mul(self, other: T) -> Self { let mut res = self; res *= other; res } } impl std::ops::DivAssign<Mint> for Mint { fn div_assign(&mut self, rhs: Self) { *self *= rhs.inv(); } } impl std::ops::DivAssign<i64> for Mint { fn div_assign(&mut self, rhs: i64) { *self /= Mint::new(rhs); } } impl<T> std::ops::Div<T> for Mint where Mint: std::ops::DivAssign<T>, { type Output = Self; fn div(self, other: T) -> Self { let mut res = self; res /= other; res } } impl std::fmt::Display for Mint { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) } } impl std::ops::Deref for Mint { type Target = i64; fn deref(&self) -> &Self::Target { &self.0 } } impl std::ops::DerefMut for Mint { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 } } fn main() { let sc = scanner::read_string(); let mut sc = scanner::Scanner::new(&sc); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); let n: usize = sc.next(); let k: usize = sc.next(); let a: Vec<usize> = sc.next_vec(n); let mut pos = vec![Mint(0); 10001]; let mut neg = vec![Mint(0); 10001]; pos[0] += 1; neg[0] += 1; let mut zero = 0; for &a in a.iter() { if a > k { let a = a - k; for i in (a..=10000).rev() { pos[i] = pos[i] + pos[i - a]; } } else if a < k { let a = k - a; for i in (a..=10000).rev() { neg[i] = neg[i] + neg[i - a]; } } else { zero += 1; } } let mut ans = Mint(0); for i in 1..=10000 { neg[i] = neg[i] + neg[i - 1]; ans += neg[i] * pos[i]; } ans *= Mint(2).pow(zero); writeln!(out, "{}", ans).unwrap(); }