結果
問題 | No.2233 Average |
ユーザー |
|
提出日時 | 2023-03-04 00:50:26 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,446 bytes |
コンパイル時間 | 29,439 ms |
コンパイル使用メモリ | 379,476 KB |
実行使用メモリ | 13,880 KB |
最終ジャッジ日時 | 2024-09-18 00:47:43 |
合計ジャッジ時間 | 22,489 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 7 TLE * 1 -- * 10 |
コンパイルメッセージ
warning: unused variable: `nc` --> src/main.rs:215:17 | 215 | let nc = (a + b) / 2; | ^^ help: if this is intentional, prefix it with an underscore: `_nc` | = note: `#[warn(unused_variables)]` on by default
ソースコード
#![allow(unused_macros, unused_imports, dead_code)]use std::any::TypeId;use std::cmp::{max, min, Reverse};use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};use std::mem::swap;use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, Sub, SubAssign};pub trait Identity {fn identity() -> Self;}impl Identity for i32 {fn identity() -> Self {1_i32}}impl Identity for u32 {fn identity() -> Self {1_u32}}impl Identity for i64 {fn identity() -> Self {1_i64}}impl Identity for u64 {fn identity() -> Self {1_u64}}impl Identity for i128 {fn identity() -> Self {1_i128}}impl Identity for u128 {fn identity() -> Self {1_u128}}impl Identity for f64 {fn identity() -> Self {1_f64}}impl Identity for usize {fn identity() -> Self {1_usize}}mod matrix {use crate::Identity;use std::iter::Sum;use std::ops::{Index, IndexMut, Mul, MulAssign, Sub};use std::slice::SliceIndex;#[derive(Clone)]pub struct Matrix<T> {h: usize,w: usize,vals: Vec<Vec<T>>,}impl<T: Clone + Copy + Identity + Sub<Output = T> + Mul + Sum<<T as Mul>::Output>> Matrix<T> {pub fn new(h: usize, w: usize) -> Self {let v1 = T::identity();#[allow(clippy::eq_op)]let v0 = v1 - v1;Self {h,w,vals: vec![vec![v0; w]; h],}}pub fn identity(h: usize, w: usize) -> Self {debug_assert!(h == w);let v1 = T::identity();#[allow(clippy::eq_op)]let v0 = v1 - v1;let mut vals = vec![vec![v0; w]; h];for (y, line) in vals.iter_mut().enumerate() {for (x, val) in line.iter_mut().enumerate() {*val = if y == x { v1 } else { v0 };}}Self { h, w, vals }}pub fn pow(&self, mut p: usize) -> Self {let mut ret = Self::identity(self.h, self.w);let mut mul = self.clone();while p > 0 {if p & 1 != 0 {ret = ret.clone() * mul.clone();}p >>= 1;mul = mul.clone() * mul.clone();}ret}}impl<T, Idx: SliceIndex<[Vec<T>]>> Index<Idx> for Matrix<T> {type Output = Idx::Output;fn index(&self, i: Idx) -> &Self::Output {&self.vals[i]}}impl<T, Idx: SliceIndex<[Vec<T>]>> IndexMut<Idx> for Matrix<T> {fn index_mut(&mut self, index: Idx) -> &mut Self::Output {&mut self.vals[index]}}impl<T: Clone + Copy + Identity + Sub<Output = T> + Mul + Sum<<T as Mul>::Output>>Mul<Matrix<T>> for Matrix<T>{type Output = Matrix<T>;fn mul(self, rhs: Matrix<T>) -> Self::Output {debug_assert!(self.w == rhs.h);let mut ret = Self::new(self.h, rhs.w);for y in 0..ret.h {for x in 0..ret.w {ret[y][x] = (0..self.w).map(|i| self[y][i] * rhs[i][x]).sum::<T>();}}ret}}impl<T: Clone + Copy + Identity + Sub<Output = T> + Mul + Sum<<T as Mul>::Output>> Mul<Vec<T>>for Matrix<T>{type Output = Vec<T>;fn mul(self, rhs: Vec<T>) -> Self::Output {debug_assert!(self.w == rhs.len());let v1 = T::identity();#[allow(clippy::eq_op)]let v0 = v1 - v1;let mut ret = vec![v0; self.h];for y in 0..self.h {ret[y] = (0..self.w).map(|x| self[y][x] * rhs[x]).sum::<T>();}ret}}impl<T: Clone + Copy + Identity + Sub<Output = T> + Mul + Sum<<T as Mul>::Output>>MulAssign<Matrix<T>> for Matrix<T>{fn mul_assign(&mut self, rhs: Matrix<T>) {*self = self.clone() * rhs;}}}use matrix::Matrix;mod procon_reader {use std::fmt::Debug;use std::io::Read;use std::str::FromStr;pub fn read<T: FromStr>() -> Twhere<T as FromStr>::Err: Debug,{let stdin = std::io::stdin();let mut stdin_lock = stdin.lock();let mut u8b: [u8; 1] = [0];loop {let mut buf: Vec<u8> = Vec::with_capacity(16);loop {let res = stdin_lock.read(&mut u8b);if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {break;} else {buf.push(u8b[0]);}}if !buf.is_empty() {let ret = String::from_utf8(buf).unwrap();return ret.parse().unwrap();}}}pub fn read_vec<T: std::str::FromStr>(n: usize) -> Vec<T>where<T as FromStr>::Err: Debug,{(0..n).into_iter().map(|_| read::<T>()).collect::<Vec<T>>()}pub fn read_vec_sub1(n: usize) -> Vec<usize> {(0..n).into_iter().map(|_| read::<usize>() - 1).collect::<Vec<usize>>()}pub fn read_mat<T: std::str::FromStr>(h: usize, w: usize) -> Vec<Vec<T>>where<T as FromStr>::Err: Debug,{(0..h).into_iter().map(|_| read_vec::<T>(w)).collect::<Vec<Vec<T>>>()}}use procon_reader::*;/**************************************************************************************************************************************************************************/fn main() {let mut ans = vec![];for _ in 0..read::<usize>() {let mut a = read::<i64>();let mut b = read::<i64>();let mut c = read::<i64>();let k = read::<usize>();for _ in 0..k {let na = (b + c) / 2;let nb = (c + a) / 2;let nc = (a + b) / 2;a = na;b = nb;c = nb;if a % 2 == 0 && b % 2 == 0 && c % 2 == 0{break;}}ans.push(a + b + c);}eprintln!();for ans in ans {println!("{}", ans);}}