Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Competitive Programming in Ruby (101)
Search
yhara
September 10, 2016
Programming
0
600
Competitive Programming in Ruby (101)
yhara
September 10, 2016
Tweet
Share
More Decks by yhara
See All by yhara
静的型付けプログラミング言語Shiika
yhara
0
17k
それは残像だ
yhara
4
4k
スモートーク
yhara
0
2.7k
Ovto: Frontend web framework for Rubyists
yhara
0
6.8k
Ruby, Opal and WebAssembly
yhara
2
2.2k
Rubyで競技プログラミング(入門編)
yhara
0
1.7k
良いデバッグログはプロジェクトの資産である
yhara
54
18k
Let's make a functional language!
yhara
0
6.1k
Recent Updates (近況報告)
yhara
0
550
Other Decks in Programming
See All in Programming
Parallel Socket Communication in Swift
s_shimotori
0
260
オブジェクト指向コードレビューの新しいアプローチ
akkie76
3
1.5k
フロントエンドパフォーマンス 入門
shouta2
7
1.5k
PHP8の機能を使って堅牢にコードを書く
fendo181
6
2.6k
Material 3で Material 2ぽい見た目にする
numeroanddev
2
250
Dockerで始めるAWS Lambda開発
stutkhd0709
14
2.5k
TCAの Shared Stateって どういう仕組みになってんの?
yimajo
0
330
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
Open Source Swift Workshop - Foundation and first party libraries
ikesyo
0
270
C# 大統一理論推進委員会 会員のための Unity Package Manager プロジェクト構成案
monry
PRO
0
580
脱・初心者!脱・マネコン!AWS CDKを使ってみませんか!?
har1101
0
180
The Future of C++ Interoperability: Insights from Porting a Game to Swift
teamhimeh
0
280
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3k
Producing Creativity
orderedlist
PRO
335
39k
Rebuilding a faster, lazier Slack
samanthasiow
72
8.2k
Become a Pro
speakerdeck
PRO
8
4.4k
Automating Front-end Workflow
addyosmani
1353
200k
GitHub's CSS Performance
jonrohan
1023
450k
What's in a price? How to price your products and services
michaelherold
236
11k
From Idea to $5000 a Month in 5 Months
shpigford
376
45k
Faster Mobile Websites
deanohume
296
30k
Why Our Code Smells
bkeepers
PRO
330
56k
Building an army of robots
kneath
300
41k
Side Projects
sachag
451
41k
Transcript
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
RubyKaigi 2016 Kyoto LT (2016-09-10) 2
Recently I'm trying Compe22ve Programming with my colleagues RubyKaigi 2016
Kyoto LT (2016-09-10) 3
Compe&&ve Programming RubyKaigi 2016 Kyoto LT (2016-09-10) 4
Programming contest RubyKaigi 2016 Kyoto LT (2016-09-10) 5
Write a program fast and correctly RubyKaigi 2016 Kyoto LT
(2016-09-10) 6
Need C(++, #) or Java? RubyKaigi 2016 Kyoto LT (2016-09-10)
7
You can use Ruby too! RubyKaigi 2016 Kyoto LT (2016-09-10)
8
Sites which supports Ruby • Sphere Online Judge • Aizu
Online Judge • yukicoder • AtCoder ←Today's topic RubyKaigi 2016 Kyoto LT (2016-09-10) 9
atcoder.jp • AtCoder Grand Contest • AtCoder Regular Contest •
AtCoder Beginner Contest • AtCoder Typical Contest RubyKaigi 2016 Kyoto LT (2016-09-10) 10
Don't join the contest RubyKaigi 2016 Kyoto LT (2016-09-10) 11
Try previous contests first ! RubyKaigi 2016 Kyoto LT (2016-09-10)
12
! • Any%me • No %me limit RubyKaigi 2016 Kyoto
LT (2016-09-10) 13
• AtCoder Grand Contest • AtCoder Regular Contest • AtCoder
Beginner Contest • AtCoder Typical Contest RubyKaigi 2016 Kyoto LT (2016-09-10) 14
AtCoder Beginner Contest • A: Very easy • B: Easy
• C: Easy? • D: Not really easy RubyKaigi 2016 Kyoto LT (2016-09-10) 15
But Ruby is slow...? ! RubyKaigi 2016 Kyoto LT (2016-09-10)
16
No problem! RubyKaigi 2016 Kyoto LT (2016-09-10) 17
Algorithm Ma-ers ! RubyKaigi 2016 Kyoto LT (2016-09-10) 18
Example: one-line Reversi RubyKaigi 2016 Kyoto LT (2016-09-10) 19
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
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
RubyKaigi 2016 Kyoto LT (2016-09-10) 22
200,000 pieces ! 200,000 ranges ! RubyKaigi 2016 Kyoto LT
(2016-09-10) 23
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
⏰ Time Limit = 2 sec. RubyKaigi 2016 Kyoto LT
(2016-09-10) 25
Be#er algorithm Memorize where color changes 10001 23005 ɹɹɹɹ↓ɹɹ↓ •••...•◦...◦•••
RubyKaigi 2016 Kyoto LT (2016-09-10) 26
Passed! ! RubyKaigi 2016 Kyoto LT (2016-09-10) 27
You can try Compe//ve Prograaming in Ruby ! (at least
for beginner contest) RubyKaigi 2016 Kyoto LT (2016-09-10) 28
! BTW ! RubyKaigi 2016 Kyoto LT (2016-09-10) 29
RubyKaigi 2016 Kyoto LT (2016-09-10) 30
ABC037-D • I couldn't pass with Ruby ! • Traversing
1000x1000 maze • Maybe with Ruby3...? RubyKaigi 2016 Kyoto LT (2016-09-10) 31
Crystal passes ※CrystalɿRuby-like sta0cally typed language RubyKaigi 2016 Kyoto LT
(2016-09-10) 32
Pypy2 passes ※Pypy2ɿFaster Python implemanta2on RubyKaigi 2016 Kyoto LT (2016-09-10)
33
Python3 passes!? ! RubyKaigi 2016 Kyoto LT (2016-09-10) 34
RubyKaigi 2016 Kyoto LT (2016-09-10) 35
RubyKaigi 2016 Kyoto LT (2016-09-10) 36
RubyKaigi 2016 Kyoto LT (2016-09-10) 37
(DON'T TRY THIS AT HOME !) RubyKaigi 2016 Kyoto LT
(2016-09-10) 38