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
競プロへの誘 -いざな-
Search
U76NER
May 16, 2022
Programming
1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
競プロへの誘 -いざな-
WASD Inc. LT会(仮)
2022-03-25
U76NER
May 16, 2022
More Decks by U76NER
See All by U76NER
JSのクラスの後ろ向きな話
u76ner
0
140
GASええやん
u76ner
1
100
mockdateええやん
u76ner
0
320
Other Decks in Programming
See All in Programming
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
230
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
4
2.7k
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
520
Make SRE Operations Easier with Azure SRE Agent
kkamegawa
0
5.1k
A2UI という光を覗いてみる
satohjohn
1
120
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
130
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
690
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.2k
Oxlintのカスタムルールの現況
syumai
6
1k
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
150
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
150
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
What's in a price? How to price your products and services
michaelherold
247
13k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.9k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
360
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Skip the Path - Find Your Career Trail
mkilby
1
140
Design in an AI World
tapps
1
230
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Transcript
競プロへの誘 -いざな- LT会(仮) 2022/03/25 u76ner
競プロとは 2 - 競プロとは - 「競技プログラミング」の略 - 競技プログラミングでは、参加者全員に同一の課題が出題され、より早く与えら れた要求を満足するプログラムを正確に記述することを競う。
(Wikipedia)
競プロとは 3 - 有名なやつの例 - AtCoder
競プロとは 4 - 有名なやつの例 - AIZU ONLINE JUDGE(AOJ)
競プロとは 5 - 問題の入力に対して解答に制限時間内に解答する - だいたい2秒とかが多い気がする(↓ AtCoderでの例)
競プロとは 6 - 問題の入力に対して解答に制限時間内に解答する
競プロとは 7 - 問題の入力に対して解答に制限時間内に解答する - 問題を解くこと自体は原理的にできるが、 ナイーブに実装すると現実的な時間で解くことが不可能 であることが多い
計算量の例 8 - 例) - a n+2 = a n+1
+ a n , a 1 = 1, a 2 = 1 - このとき、a 40 , a 100 を求めよ - いわゆるフィボナッチ数列
計算量の例 9 - ナイーブな実装
計算量の例 10 - ナイーブな実装 - a 100 が計算できない
- 計算時間 - a 40 : 604 ms - a 45 : 6,808 ms - a 50 : > 1 min
計算量の例 11 - 改善点 - a 50 = a
49 + a 48 = (a 48 + a 47 ) + (a 47 + a 46 ) = (a 47 + a 46 ) + (a 46 + a 45 ) + (a 46 + a 45 ) + (a 45 + a 44 ) = …
計算量の例 12 - 改善点 - a 50 = a
49 + a 48 = (a 48 + a 47 ) + (a 47 + a 46 ) = (a 47 + a 46 ) + (a 46 + a 45 ) + (a 46 + a 45 ) + (a 45 + a 44 ) = … - 重複した計算を上手く記憶しておくことで速くできそう
計算量の例 13 - 途中計算を記憶しておく実装
計算量の例 14 - 途中計算を記憶しておく実装 - 計算時間 -
a 40 : ≒ 1ms - a 100 : ≒ 1ms - ちなみにこういうアルゴリズムを総称して動的計画法(DP)という
エンジニアの視点から 15 - 競プロをやることの利点
エンジニアの視点から 16 - 競プロをやることの利点 - 処理を軽くすることに目が向きやすい
エンジニアの視点から 17 - 例)
エンジニアの視点から 18 - ナイーブにやる - 二重ループは改善できそう
エンジニアの視点から 19 - 連想配列を使う -
二重ループが解消できる
まとめ 20 - 競プロでは、計算方法自体はすぐわかるけど、 それを現実的な時間で計算できるかが求められる - 普段の実装でも、細かい計算量の削減に目が行き届くようになる
21