結果
問題 |
No.1304 あなたは基本が何か知っていますか?私は知っています.
|
ユーザー |
|
提出日時 | 2020-12-01 19:38:59 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,541 bytes |
コンパイル時間 | 18,128 ms |
コンパイル使用メモリ | 399,892 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-06-22 02:41:49 |
合計ジャッジ時間 | 17,642 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 27 WA * 18 RE * 29 |
コンパイルメッセージ
warning: unused imports: `collections::BTreeMap`, `collections::BTreeSet`, `ops::AddAssign`, `ops::Neg`, `ops::RangeInclusive`, and `rc::Rc` --> src/main.rs:1:11 | 1 | use std::{collections::BTreeMap, collections::BTreeSet, ops::AddAssign, ops::Neg, ops::RangeInclusive, rc::Rc}; | ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: unused imports: `collections::HashMap`, `collections::HashSet`, `ops::Add`, `ops::Div`, `ops::Mul`, and `ops::Sub` --> src/main.rs:2:11 | 2 | use std::{ops::Add, ops::Sub, ops::Mul, ops::Div, collections::HashMap, collections::HashSet}; | ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ warning: unused import: `std::cmp::Reverse` --> src/main.rs:3:5 | 3 | use std::cmp::Reverse; | ^^^^^^^^^^^^^^^^^ warning: unused imports: `BinaryHeap` and `VecDeque` --> src/main.rs:4:24 | 4 | use std::collections::{VecDeque, BinaryHeap}; | ^^^^^^^^ ^^^^^^^^^^ warning: unused import: `std::str::FromStr` --> src/main.rs:5:5 | 5 | use std::str::FromStr; | ^^^^^^^^^^^^^^^^^ warning: unused import: `std::fmt::Display` --> src/main.rs:6:5 | 6 | use std::fmt::Display; | ^^^^^^^^^^^^^^^^^ warning: unused import: `std::cmp::max` --> src/main.rs:7:5 | 7 | use std::cmp::max; | ^^^^^^^^^^^^^ warning: unused imports: `DivAssign`, `IndexMut`, `Index`, `MulAssign`, and `SubAssign` --> src/main.rs:11:16 | 11 | use std::ops::{Index, IndexMut, SubAssign, MulAssign, DivAssign}; | ^^^^^ ^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^ warning: unused imports: `Hash` and `Hasher` --> src/main.rs:12:17 | 12 | use std::hash::{Hash, Hasher}; | ^^^^ ^^^^^^ warning: unused import: `std::collections::hash_map::Entry::Vacant` --> src/main.rs:13:5 | 13 | use std::collections::hash_map::Entry::
ソースコード
use std::{collections::BTreeMap, collections::BTreeSet, ops::AddAssign, ops::Neg, ops::RangeInclusive, rc::Rc}; use std::{ops::Add, ops::Sub, ops::Mul, ops::Div, collections::HashMap, collections::HashSet}; use std::cmp::Reverse; use std::collections::{VecDeque, BinaryHeap}; use std::str::FromStr; use std::fmt::Display; use std::cmp::max; use std::cmp::min; use std::cmp::Ordering; use std::fmt::Debug; use std::ops::{Index, IndexMut, SubAssign, MulAssign, DivAssign}; use std::hash::{Hash, Hasher}; use std::collections::hash_map::Entry::Vacant; use std::io::BufRead; use std::borrow::Borrow; const PARSE_ERROR: &str = "Can't Parse"; const EOF_ERROR: &str = "No Line"; macro_rules! freeze { ($($id:ident), *) => { $(let $id = $id;)* }; } macro_rules! read_line { () => { { let mut buffer = String::new(); std::io::stdin().read_line(&mut buffer).expect(EOF_ERROR); buffer.trim().to_owned() } }; (&mut $buffer: ident) => { { std::io::stdin().read_line(&mut $buffer).expect(EOF_ERROR); $buffer.trim().to_owned() } }; } macro_rules! read { () => { read_line!() }; ([[char]; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!([char])).collect::<Vec<_>>() }; ([[$ty:ty]; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!([$ty])).collect::<Vec<_>>() }; ([$ty:ty; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!($ty)).collect::<Vec<_>>() }; ([$block: block; $size: expr]) => { (0 .. $size).into_iter().map(|_| read!($block)).collect::<Vec<_>>() }; ([$($tt: tt)*] ASC) => { { read!(mut vec: [$($tt)*]); vec.sort(); vec } }; ([$($tt: tt)*] DESC) => { { read!(mut vec: [$($tt)*]); vec.sort_by_key(|&v| Reverse(v)); vec } }; ([char]) => { read_line!().chars().collect::<Vec<_>>() }; ([String]) => { read_line!().split_whitespace().map(|s| s.to_owned()).collect::<Vec<String>>(); }; ([$ty: ty]) => { read_line!().split_whitespace().map(|x| x.parse().ok().expect(PARSE_ERROR)).collect::<Vec<$ty>>() }; ($ty: ty) => { read_line!().parse::<$ty>().ok().expect(PARSE_ERROR) }; ($block: block) => { $block }; ($ident: ident: [$($tt:tt)*]) => { let $ident = read!([$($tt)*]); }; (mut $ident: ident: [$($tt:tt)*]) => { let mut $ident = read!([$($tt)*]); }; ($ident: ident: [$($tt:tt)*] ASC) => { let $ident = read!([$($tt)*] ASC); }; ($ident: ident: [$($tt:tt)*] DESC) => { let $ident = read!([$($tt)*] DESC); }; ($ident: ident: String) => { let $ident = read!(); }; (mut $ident: ident: String) => { let mut $ident = read!(); }; ($($token: tt)*) => { let line = read_line!(); let mut iter = line.split_whitespace().into_iter(); read_from_iter!(iter; $($token)*); }; } macro_rules! read_from_iter { ($iter:expr; mut $ident:ident:$ty:ty, $($rest:tt)*) => { let mut $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); read_from_iter!($iter; $($rest)*); }; ($iter:expr; $ident:ident:$ty:ty, $($rest:tt)*) => { let $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); read_from_iter!($iter; $($rest)*); }; ($iter:expr; mut $ident:ident:$ty:ty) => { let mut $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); }; ($iter:expr; $ident:ident:$ty:ty) => { let $ident = $iter.next().unwrap().parse::<$ty>().expect(PARSE_ERROR); }; ($iter: expr; ) => {}; } struct KeyValue<K, V> { key: K, value: V } impl <K: PartialOrd, V> PartialEq for KeyValue<K, V> { fn eq(&self, other: &Self) -> bool { self.key.eq(&other.key) } } impl <K: PartialOrd, V> Eq for KeyValue<K, V> {} impl <K: PartialOrd, V> PartialOrd for KeyValue<K, V> { fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { self.key.partial_cmp(&other.key) } } impl <K: PartialOrd, V> Ord for KeyValue<K, V> { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.key.partial_cmp(&other.key).ok_or("Can't Compare").unwrap() } } fn sorted<T: Ord>(mut vec: Vec<T>) -> Vec<T> { vec.sort(); vec } #[derive(Copy, Clone, Debug, PartialEq, PartialOrd)] struct OrdF64(f64); impl Ord for OrdF64 { fn cmp(&self, other: &Self) -> Ordering { self.0.partial_cmp(&other.0).unwrap() } } impl Eq for OrdF64 {} fn main() { read!(n: usize, k: usize, x: usize, y: usize); read!(values: [usize]); const MOD: i64 = 9982443353; let mut count = vec![0; 1 << 10]; for v in values { count[v] += 1; } let mut memo = vec![vec![0i64; 1 << 10]; n + 1]; memo[0][0] = 1; for i in 1 ..= n { for x in 0..1024 { for y in 0..1024 { memo[i][x] += memo[i - 1][x ^ y] * count[y] % MOD; if i >= 3 { memo[i][x] += memo[i - 3][x ^ y] * count[y] % MOD; } } if i >= 2 { memo[i][x] = (memo[i][x] - memo[i - 2][x] * (k as i64) % MOD + MOD) % MOD } } } let mut result = 0; for i in x ..= min(y, 1023) { result += memo[n][i]; } println!("{}", result % MOD); }