Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Competitive programming by Rust

fnwiya
September 05, 2018

Competitive programming by Rust

fnwiya

September 05, 2018
Tweet

More Decks by fnwiya

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ • Kohno Fumiya ( @fnwiya ) • Japan Venture

    Research Co., LTD. • React Native & Ruby on Rails • RustΛۀ຿ʹಋೖ͍ͨ͠ʢ͢Δʣ
  2. Rustacean͕ڝϓϩΛ͢΂͖ཧ༝ • ࡞Γ͍ͨ΋ͷ͕ͳͯ͘΋໰୊͕͋Δ • ؀ڥߏஙෆཁ • Rustಛ༗ͳ͜ͱ͸Ұ௨Γ৮ΕΒΕΔ • String vs

    Vec<char>ͳͲจࣈྻͷѻ͍ • ύλʔϯϚονɺmap().collect()ɺॴ༗ݖ • ࣮ߦ଎౓ ≒ C++
  3. RustͰڝϓϩ͢Δͱ͖ͷ஫ҙ఺ • ඪ४ೖྗ use std::io::*; use std::str::FromStr; fn read<T: FromStr>()

    -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().expect("failed to parse token") } https://qiita.com/tubo28/items/ e6076e9040da57368845#%E5%85%A5%E5%87%BA%E5%8A%9B
  4. Rust͕࢖͑ΔڝϓϩαΠτ • AtCoder • HackerRank • AOJ • ☓ topsider

    ·ͣ AtCoder ʹొ࿥ͨ͠Β࣍ʹ΍Δ͜ͱ ʙ ͜Ε͚ͩղ͚͹े෼ಆ͑Δʂաڈ໰ਫ਼બ 10 ໰ ʙ( https://qiita.com/drken/items/fd4e5e3630d0f5859067#5- %E9%81%8E%E5%8E%BB%E5%95%8F%E7%B2%BE%E9%81%B8-10- %E5%95%8F ) ͕͓͢͢Ί