competitive/tools/
main.rs1#![allow(dead_code)]
2#![allow(clippy::crate_in_macro_def)]
3
4#[codesnip::skip]
5use crate::tools::{Scanner, read_stdin_all_unchecked};
6
7#[cfg_attr(any(), rust_minify::skip)]
8pub fn solve() {
9 crate::prepare!();
10 sc!(_n);
11}
12
13crate::main!();
14
15#[allow(unused_imports)]
16use std::{
17 cmp::{Ordering, Reverse},
18 collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque},
19};
20
21mod main_macros {
22 #[macro_export]
26 #[allow(clippy::crate_in_macro_def)]
27 macro_rules! prepare {
28 (@output ($dol:tt)) => {
29 #[allow(unused_imports)]
30 use std::io::Write as _;
31 let __out = std::io::stdout();
32 #[allow(unused_mut,unused_variables)]
33 let mut __out = std::io::BufWriter::new(__out.lock());
34 #[allow(unused_macros)]
35 macro_rules! pp { ($dol($dol t:tt)*) => { $dol crate::iter_print!(__out, $dol($dol t)*) } }
37 #[cfg(debug_assertions)]
38 #[allow(unused_macros)]
39 macro_rules! dg {
41 ($dol($dol t:tt)*) => {{
42 #[allow(unused_imports)]
43 use std::io::Write as _;
44 let __err = std::io::stderr();
45 #[allow(unused_mut,unused_variables)]
46 let mut __err = std::io::BufWriter::new(__err.lock());
47 $dol crate::iter_print!(__err, $dol($dol t)*);
48 let _ = __err.flush();
49 }}
50 }
51 #[cfg(not(debug_assertions))]
52 #[allow(unused_macros)]
53 macro_rules! dg { ($dol($dol t:tt)*) => {} }
55 };
56 (@normal ($dol:tt)) => {
57 let __in_buf = read_stdin_all_unchecked();
58 #[allow(unused_mut,unused_variables)]
59 let mut __scanner = Scanner::new(&__in_buf);
60 #[allow(unused_macros)]
61 macro_rules! sc { ($dol($dol t:tt)*) => { $dol crate::scan!(__scanner, $dol($dol t)*) } }
62 #[allow(unused_macros)]
63 macro_rules! sv { ($dol($dol t:tt)*) => { $dol crate::scan_value!(__scanner, $dol($dol t)*) } }
64 };
65 (@interactive ($dol:tt)) => {
66 #[allow(unused_macros)]
67 macro_rules! scln {
69 ($dol($dol t:tt)*) => {
70 let __in_buf = read_stdin_line();
71 #[allow(unused_mut,unused_variables)]
72 let mut __scanner = Scanner::new(&__in_buf);
73 $dol crate::scan!(__scanner, $dol($dol t)*)
74 }
75 }
76 #[allow(unused_macros)]
77 macro_rules! svln {
79 ($dol($dol t:tt)*) => {{
80 let __in_buf = read_stdin_line();
81 #[allow(unused_mut,unused_variables)]
82 let mut __scanner = Scanner::new(&__in_buf);
83 $dol crate::scan_value!(__scanner, $dol($dol t)*)
84 }}
85 }
86 };
87 () => { $crate::prepare!(@output ($)); $crate::prepare!(@normal ($)) };
88 (?) => { $crate::prepare!(@output ($)); $crate::prepare!(@interactive ($)) };
89 }
90 #[macro_export]
91 macro_rules! main {
92 () => {
93 fn main() {
94 solve();
95 }
96 };
97 (avx2) => {
98 fn main() {
99 #[target_feature(enable = "avx2")]
100 unsafe fn solve_avx2() {
101 solve();
102 }
103 unsafe { solve_avx2() }
104 }
105 };
106 (large_stack) => {
107 fn main() {
108 const STACK_SIZE: usize = 512 * 1024 * 1024;
109 ::std::thread::Builder::new()
110 .stack_size(STACK_SIZE)
111 .spawn(solve)
112 .unwrap()
113 .join()
114 .unwrap();
115 }
116 };
117 }
118}