Submission #36693345
Source Code Expand
#![allow(unused_macros, unused_imports)]
use std::cmp::*;
use std::collections::*;
// $ cp-batch all_assign_point_add | diff all_assign_point_add.out -
// $ cargo run --bin all_assign_point_add
///
/// 11/20/2022
///
/// 18:18-18:44 WA
///
fn solve() -> Vec<i64> {
let _n = readln!(usize);
let mut a = readln!([i64]).iter().map(|&a| (-1, a)).collect_vec();
let q = readln!(isize);
let mut cur_all = (-10, 0);
let mut res = vec![];
for t in 0..q {
let s = readln!([usize]);
// dbgln!(s);
match s[0] {
1 => {
cur_all = (t, s[1] as i64);
}
2 => {
let i = s[1] - 1;
if a[i].0.setmax(cur_all.0) {
a[i].1 = cur_all.1;
}
a[i].1 += s[2] as i64;
}
3 => {
let i = s[1] - 1;
let (tt, val) = a[i];
let ans = if tt < cur_all.0 { cur_all.1 } else { val };
res.push(ans);
}
_ => unreachable!(),
}
}
res
}
fn main() {
setup_out!(put, puts);
let res = solve();
for res in res {
puts!("{}", res);
}
}
// #[test]
// fn test_bruteforce() {
// loop {
// let mut rng = thread_rng();
// let n = 5;
// let m = 5;
// let ab = (0..n)
// .map(|_| (rng.gen_range(1, 6), rng.gen_range(1, 6)))
// .collect_vec();
// let exp = solve_v0_shxt_impl(n, m, &ab, true);
// let act = solve_v0_shxt_impl(n, m, &ab, false);
// if act != exp {
// dbgln!(act, exp, ab);
// }
// assert_eq!(act, exp);
// }
// }
use crate::cplib::io::*;
use crate::cplib::minmax::*;
use crate::cplib::vec::*;
// region: cplib
#[rustfmt::skip]
#[allow(dead_code)]
pub mod cplib {
pub mod io {
macro_rules! _with_dollar_sign { ($($body:tt)*) => { macro_rules! __with_dollar_sign { $($body)* } __with_dollar_sign!($); }}
macro_rules! setup_out {
($fn:ident,$fn_s:ident) => {
use std::io::Write;
let out = std::io::stdout();
let mut out = ::std::io::BufWriter::new(out.lock());
_with_dollar_sign! { ($d:tt) => {
macro_rules! $fn { ($d($format:tt)*) => { let _ = write!(out,$d($format)*); } }
macro_rules! $fn_s { ($d($format:tt)*) => { let _ = writeln!(out,$d($format)*); } }
}}
};
}
macro_rules! _epr { ($v:expr $(,)?) => {eprint!("{} = {:?}, ", stringify!($v), $v)}; }
macro_rules! dbgln { ($($val:expr),*) => {{ eprint!("[{}:{}] ", file!(), line!()); ($(_epr!($val)),*); eprintln!(); }}; }
pub fn readln_str() -> String {
let mut line = String::new();
::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
line
}
macro_rules! _read {
($it:ident; [char]) => { _read!($it; String).chars().collect::<Vec<_>>() };
($it:ident; [u8]) => { Vec::from(_read!($it; String).into_bytes()) };
($it:ident; usize1) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1 };
($it:ident; [usize1]) => { $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>() };
($it:ident; [$t:ty]) => { $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>() };
($it:ident; $t:ty) => { $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e)) };
($it:ident; $($t:tt),+) => { ($(_read!($it; $t)),*) };
}
macro_rules! readlns {
($($t:tt),*; $n:expr) => {{ let stdin = ::std::io::stdin();
::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
let line = line.unwrap(); #[allow(unused_mut)]let mut it = line.split_whitespace(); _read!(it; $($t),*)
}).collect::<Vec<_>>()
}};
}
macro_rules! readln {
($($t:tt),*) => {{ let line = cplib::io::readln_str(); #[allow(unused_mut)]let mut it = line.split_whitespace(); _read!(it; $($t),*) }};
}
pub(crate) use {readlns, readln, setup_out, dbgln, _with_dollar_sign, _epr, _read};
}
pub mod minmax {
pub trait SetMinMax {
fn setmin(&mut self, other: Self) -> bool;
fn setmax(&mut self, other: Self) -> bool;
}
macro_rules! _set { ($self:ident, $cmp:tt, $other:ident) => {{
let update = $other $cmp *$self;
if update { *$self = $other; }
update
}}; }
impl<T> SetMinMax for T where T: PartialOrd {
fn setmin(&mut self, other: T) -> bool { _set!(self, <, other) }
fn setmax(&mut self, other: T) -> bool { _set!(self, >, other) }
}
}
pub mod vec {
pub trait CollectVec: Iterator { fn collect_vec(self) -> Vec<Self::Item> where Self: Sized { self.collect() } }
impl<T> CollectVec for T where T: Iterator {}
macro_rules! vvec {
($v:expr; $n:expr) => { Vec::from(vec![$v; $n]) };
($v:expr; $n:expr $(; $ns:expr)+) => { Vec::from(vec![vvec![$v $(; $ns)*]; $n]) };
}
pub(crate) use vvec;
}
}
// endregion: cplib
Submission Info
| Submission Time |
|
| Task |
D - All Assign Point Add |
| User |
kumalimak |
| Language |
Rust (1.42.0) |
| Score |
400 |
| Code Size |
4985 Byte |
| Status |
AC |
| Exec Time |
65 ms |
| Memory |
6692 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
400 / 400 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_N_small_03.txt, 01_N_small_04.txt, 01_N_small_05.txt, 01_N_small_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 03_max_11.txt, 04_handmade_12.txt, 04_handmade_13.txt, 04_handmade_14.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_00.txt |
AC |
6 ms |
2040 KiB |
| 00_sample_01.txt |
AC |
2 ms |
2000 KiB |
| 00_sample_02.txt |
AC |
1 ms |
2056 KiB |
| 01_N_small_03.txt |
AC |
52 ms |
2684 KiB |
| 01_N_small_04.txt |
AC |
45 ms |
2304 KiB |
| 01_N_small_05.txt |
AC |
53 ms |
2236 KiB |
| 01_N_small_06.txt |
AC |
54 ms |
3408 KiB |
| 02_random_07.txt |
AC |
48 ms |
4272 KiB |
| 02_random_08.txt |
AC |
52 ms |
5784 KiB |
| 02_random_09.txt |
AC |
42 ms |
4224 KiB |
| 02_random_10.txt |
AC |
55 ms |
5056 KiB |
| 03_max_11.txt |
AC |
65 ms |
6604 KiB |
| 04_handmade_12.txt |
AC |
58 ms |
4532 KiB |
| 04_handmade_13.txt |
AC |
53 ms |
4008 KiB |
| 04_handmade_14.txt |
AC |
60 ms |
6692 KiB |