Rust Competitive Helper
Rust Competitive Helper is a template for competitive programming in Rust, written by Egor and adapted as a separate project by qwerty787788.
The use of a template in competitive programming is very useful because it saves time for repetitive tasks such as reading input and writing output.
Rust competitive helper works well with Competitive Companion, guides and tutorial are avalaible in Readme.md of the relevant Github repositories. From now on it will be assumed that rust competitive helper is set up correctly.
The main function where we are going to solve the problem looks like this:
use algo_lib::io::input::Input;
use algo_lib::io::output::output;
use algo_lib::{out, out_line};
fn solve(input: &mut Input, _test_case: usize) {
// solution comes here
}
pub(crate) fn run(mut input: Input) -> bool {
// this part automatically changes based on problem typology:
// (1) number of tests given
// (2) one test only
// (3) EOF
}
//START MAIN
mod tester;
fn main() {
tester::run_tests();
}
//END MAIN
The code can be compiled using the following command
cargo build --bin name_of_the_problem_bin
The solution will be compiled in the main.rs
file of the main package (not in the main.rs
file of the compiled bin where solve()
function is located)