Блог пользователя cotton

Автор cotton, история, 3 года назад, По-английски

In 2021 July, I posted a blog Use Rust in Codeforce — My practice with rust-bundler. After some work, I published a new package rust_bundler_cp, which is designed for competitive programming, and concentrating on codeforces' environment.

Quick guide:

  1. cargo install rust_bundler_cp
  2. git clone https://github.com/Endle/rust_codeforce_template.git --depth=1
  3. cd rust_codeforce_template
  4. rust_bundler_cp --input . --output /dev/shm/bundled.rs

I'm excited to introduce a new feature (experimental): Remove unused pub mod At top of my lib.rs, I have several pub mod as my code template.

pub mod pr;
pub mod algo;
pub mod nd;
pub mod multi_queue;
pub mod nums;
pub mod iters;

Although Codeforces has a generous code size limit: 64kb, it's always better to avoid unnecessary code. My new version rust_bundler_cp may examine main.rs. If a mod is not used in main.rs, it would be removed from the final output with explicit arg:
rust_bundler_cp --input . --output /dev/shm/bundled.rs --remove_unused_mod

Looking forward to your feedback!

Полный текст и комментарии »

  • Проголосовать: нравится
  • +2
  • Проголосовать: не нравится

Автор cotton, история, 3 года назад, По-английски

In June 2019, EbTech posted an article How to Compete in Rust. Inspired by that, I'm working on my rust_codeforce_template.

It could be used in such way:

  1. cargo install --git https://github.com/Endle/rust-bundler.git --branch codeforce bundler
  2. git clone https://github.com/Endle/rust_codeforce_template.git --depth=1
  3. Edit main.rs. Most cases, I only need to edit fn solve()
  4. ./run_with_bundle.sh < test.in
  5. If the result looks good, submit /dev/shm/output.rs to codeforce

This workflow has such advantages IMHO

Clean main.rs
Template code Move template code out of main.rs. I could save my time from scrolling up and down. My forked rust-bundler would bundle them into a single file that could be submitted.

Save coding time for IO
I bundled text_io in my lib.rs. It provides simple reading methods
let i: i32 = read!(); let word: String = read!();
Based on that, I added another function read_ivec. I think this is the most frequently used function in my template.

I'm new and naive to both Rust and competitive programming. (Well, old and naive for the latter). I'll be so grateful for your comments.

Besides, I recommend rust-algorithms by EbTech. Templates with a high quality:)

Полный текст и комментарии »

  • Проголосовать: нравится
  • +12
  • Проголосовать: не нравится