Skip to content

Instantly share code, notes, and snippets.

@tokugh
Created June 9, 2021 11:55
Show Gist options
  • Save tokugh/c2777248fe78452eee116eff13871891 to your computer and use it in GitHub Desktop.
Save tokugh/c2777248fe78452eee116eff13871891 to your computer and use it in GitHub Desktop.
use proconio::{input, fastout};
use std::collections::VecDeque;
const QMAX: usize = 100000;
#[fastout]
fn main() {
let mut data = VecDeque::with_capacity(QMAX);
input! { tx: [(usize, usize)], };
for txi in tx {
match txi {
(1, x) => data.push_front(x),
(2, x) => data.push_back(x),
(3, x) => println!("{}", data[x-1]),
_ => unreachable!(),
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment