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

Competitive Programming in Ruby (101)

yhara
September 10, 2016

Competitive Programming in Ruby (101)

yhara

September 10, 2016
Tweet

More Decks by yhara

Other Decks in Programming

Transcript

  1. Compe&&ve Programming in Ruby (101) RubyKaigi 2016 Kyoto A1er Party

    LT (2016-09-10) @yhara (Yutaka Hara) RubyKaigi 2016 Kyoto LT (2016-09-10) 1
  2. Sites which supports Ruby • Sphere Online Judge • Aizu

    Online Judge • yukicoder • AtCoder ←Today's topic RubyKaigi 2016 Kyoto LT (2016-09-10) 9
  3. atcoder.jp • AtCoder Grand Contest • AtCoder Regular Contest •

    AtCoder Beginner Contest • AtCoder Typical Contest RubyKaigi 2016 Kyoto LT (2016-09-10) 10
  4. • AtCoder Grand Contest • AtCoder Regular Contest • AtCoder

    Beginner Contest • AtCoder Typical Contest RubyKaigi 2016 Kyoto LT (2016-09-10) 14
  5. AtCoder Beginner Contest • A: Very easy • B: Easy

    • C: Easy? • D: Not really easy RubyKaigi 2016 Kyoto LT (2016-09-10) 15
  6. one-line Reversi • Given N pieces, flip Q ranges •

    Calculate the final state ••••••••• 1..4 2..6 8..9 ɹɹ↓ ◦•••◦◦•◦◦ RubyKaigi 2016 Kyoto LT (2016-09-10) 20
  7. Just flipping each pieces? ranges.each do |r| r.each do |i|

    line[i] = !line[i] end end RubyKaigi 2016 Kyoto LT (2016-09-10) 21
  8. Billions of flips ! ranges.each do |r| # <- 200,000

    times r.each do |i| # <- 50,000 times or so line[i] = !line[i] end end RubyKaigi 2016 Kyoto LT (2016-09-10) 24
  9. You can try Compe//ve Prograaming in Ruby ! (at least

    for beginner contest) RubyKaigi 2016 Kyoto LT (2016-09-10) 28
  10. ABC037-D • I couldn't pass with Ruby ! • Traversing

    1000x1000 maze • Maybe with Ruby3...? RubyKaigi 2016 Kyoto LT (2016-09-10) 31