Competitive programming by Rust

7330cbbb623c60949c5470b7eb97c3ca?s=47 fnwiya
September 05, 2018

Competitive programming by Rust

7330cbbb623c60949c5470b7eb97c3ca?s=128

fnwiya

September 05, 2018
Tweet

Transcript

  1. Rustॳ৺ऀ͸ ·ͣڝϓϩ͔Β࢝ΊͨΒ ྑͦ͞͏ͬͯ࿩

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

    Research Co., LTD. • React Native & Ruby on Rails • RustΛۀ຿ʹಋೖ͍ͨ͠ʢ͢Δʣ
  3. ৽͍͠ݴޠͷशಘʹ͸ ࣗ෼ͷ࡞Γ͍ͨ΋ͷΛ࡞ΔաఔͰ ֶͿͷ͕ϕετ

  4. ڝϓϩͱ͸ ڝٕϓϩάϥϛϯάʢӳޠ: Competitive programmingɺུশ: ڝϓϩʣͱ͸ɺ ϓϩάϥϛϯάίϯςετͰߦΘΕΔڝٕͷҰछͰ͋Δɻ ڝٕϓϩάϥϛϯάͰ͸ɺࢀՃऀશһʹಉҰͷ՝୊͕ग़୊͞ΕɺΑΓૣ͘༩͑ ΒΕͨཁٻΛຬ଍͢ΔϓϩάϥϜΛਖ਼֬ʹهड़͢Δ͜ͱΛڝ͏ɻίϯϐϡʔλ αΠΤϯε΍਺ֶͷ஌ࣝΛඞཁͱ͢Δ໰୊͕ଟ͘ɺ৽ଔֶੜͷ࠾༻׆ಈͳͲʹ ࢖ΘΕΔ͜ͱ΋͋Δɻଟ͘ͷίϯςετͰΦϯϥΠϯδϟοδ͕࠾༻͞Ε͍ͯ

    Δɻ ·ͨɺڝٕϓϩάϥϛϯάʹࢀՃ͢ΔਓΛʮڝٕϓϩάϥϚʯ·ͨ͸ʮڝϓϩ erʯͱݺͿ͜ͱ͕͋Δɻ https://ja.wikipedia.org/wiki/ڝٕϓϩάϥϛϯά
  5. ྫʣࣗવ਺ a , b͕༩͑ΒΕ·͢ɻ a ͱ b ͷ࿨͕ૉ਺ͳΒYes, ૉ਺Ҏ ֎ͳΒNoΛग़ྗ͍ͯͩ͘͠͞ɻ

    (a, b < 1000)
  6. Rustacean͕ڝϓϩΛ͢΂͖ཧ༝ • ࡞Γ͍ͨ΋ͷ͕ͳͯ͘΋໰୊͕͋Δ • ؀ڥߏஙෆཁ • Rustಛ༗ͳ͜ͱ͸Ұ௨Γ৮ΕΒΕΔ • String vs

    Vec<char>ͳͲจࣈྻͷѻ͍ • ύλʔϯϚονɺmap().collect()ɺॴ༗ݖ • ࣮ߦ଎౓ ≒ C++
  7. 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
  8. ڝϓϩͰ͸਎ʹ͔ͭͳ͍͜ͱ • ςετ • Ϟδϡʔϧ • νʔϜ։ൃ

  9. 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 ) ͕͓͢͢Ί
  10. None