add 11505.rs
This commit is contained in:
40
storage/zeta/rs/11505.rs
Normal file
40
storage/zeta/rs/11505.rs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
use std::io::{read_to_string, stdin};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
struct SegTree<T: Clone, F> where F: Fn(T, T) -> T{
|
||||||
|
pub operation: F,
|
||||||
|
size: usize,
|
||||||
|
tree: Vec<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Clone, F> SegTree<T, F> where F: Fn(T, T) -> T {
|
||||||
|
fn new(arr: &Vec<T>, op: F) -> Self {
|
||||||
|
let size = arr.len();
|
||||||
|
|
||||||
|
let mut tree = vec![arr[0].clone();size * 4];
|
||||||
|
|
||||||
|
let mut stack = vec![]; // (inst, index, [lo, hi))
|
||||||
|
|
||||||
|
stack.push((1, 0, 0, size));
|
||||||
|
stack.push((0, 0, 0, size));
|
||||||
|
|
||||||
|
while !stack.is_empty() {
|
||||||
|
let (inst, index, lo, hi) = stack.pop().unwrap();
|
||||||
|
if inst == 0 {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SegTree { operation: op, size, tree: tree }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let temp = read_to_string(stdin()).unwrap();
|
||||||
|
let mut iter = temp
|
||||||
|
.split_ascii_whitespace()
|
||||||
|
.map(|x| x.parse::<usize>().unwrap());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user