結果
問題 |
No.2344 (l+r)^2
|
ユーザー |
![]() |
提出日時 | 2023-06-09 21:14:11 |
言語 | Rust (1.83.0 + proconio) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,947 bytes |
コンパイル時間 | 11,349 ms |
コンパイル使用メモリ | 401,668 KB |
実行使用メモリ | 13,636 KB |
最終ジャッジ日時 | 2025-01-02 01:58:44 |
合計ジャッジ時間 | 19,566 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 11 TLE * 1 |
コンパイルメッセージ
warning: unused import: `std::collections::*` --> src/main.rs:31:5 | 31 | use std::collections::*; | ^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_imports)]` on by default
ソースコード
// ---------- begin scannner ---------- #[allow(dead_code)] mod scanner { use std::str::FromStr; pub struct Scanner<'a> { it: std::str::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 { self.it.next().unwrap().parse::<T>().ok().unwrap() } pub fn next_bytes(&mut self) -> Vec<u8> { self.it.next().unwrap().bytes().collect() } pub fn next_chars(&mut self) -> Vec<char> { self.it.next().unwrap().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } } // ---------- end scannner ---------- use std::io::Write; use std::collections::*; fn main() { use std::io::Read; let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut sc = scanner::Scanner::new(&s); let out = std::io::stdout(); let mut out = std::io::BufWriter::new(out.lock()); run(&mut sc, &mut out); } fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) { let t: u32 = sc.next(); for _ in 0..t { let n: usize = sc.next(); let m: u32 = sc.next(); let a = sc.next_vec::<u32>(n); let ans = unsafe { solve(a, m) }; writeln!(out, "{}", ans).ok(); } } #[target_feature(enable = "avx2")] unsafe fn solve(mut a: Vec<u32>, m: u32) -> u32 { let mut next = Vec::with_capacity(a.len()); for _ in 1..a.len() { next.clear(); next.extend(&a[1..]); for (next, a) in next.iter_mut().zip(a.iter()) { *next = (*next + *a) * (*next + *a); } std::mem::swap(&mut a, &mut next); } a[0] % (1 << m) }