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
Rustで始める競技プログラミング
Search
minami
September 17, 2019
Programming
0
290
Rustで始める競技プログラミング
Rustで始める競技プログラミング
minami
September 17, 2019
Tweet
Share
More Decks by minami
See All by minami
Autocxx -RustからC++を安全かつ楽に-
minaminao
2
1.2k
Account/Balanceモデルのシャーディングと課題点
minaminao
1
680
Other Decks in Programming
See All in Programming
CSC509 Lecture 09
javiergs
PRO
0
140
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
900
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
Ethereum_.pdf
nekomatu
0
460
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
最新TCAキャッチアップ
0si43
0
140
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
CSC509 Lecture 11
javiergs
PRO
0
180
cmp.Or に感動した
otakakot
2
150
Quine, Polyglot, 良いコード
qnighy
4
640
シェーダーで魅せるMapLibreの動的ラスタータイル
satoshi7190
1
480
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Happy Clients
brianwarren
98
6.7k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Building a Scalable Design System with Sketch
lauravandoore
459
33k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
KATA
mclloyd
29
14k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Transcript
3VTUͰ࢝ΊΔ ڝٕϓϩάϥϛϯά NJOBNJOBP SPQQPOHJST
Ԭೆ࠸ NJOBNJOBP !WJOBNJ ࣗݾհ ஜେֶใֶ܈ใՊֶྨ d-BZFS93%νʔϜ
ڝϓϩͱ ಘΒΕΔͷ ࣍ ·ͱΊ
ڝٕϓϩάϥϛϯάͱ ͕༩͑ΒΕΔ ɾ࣮ߦ࣌ؒͱϝϞϦ༻ྔͷ্ݶ͖ ͦΕΛղ͘ϓϩάϥϜΛ࣮ˍఏग़ αʔόʔ͕ਖ਼ղ͔ఆ ղ͚͕ͨଟ͍ํ͕উͪ
ڝϓϩͰಘΒΕΔͷ ɾϓϩάϥϛϯάݴޠͷࣝͱ࣮ྗ ɾղܾྗɺཧతࢥߟྗɺֶྗ ɾߴͳϓϩάϥϜͷ࣮ํ๏ ΞϧΰϦζϜͱσʔλߏ
ΞϧΰϦζϜͱσʔλߏ ߹ֶͤɺแআݪཧɺׂɺηάϝϯτπϦʔɺฏํׂɺώʔϓɺ#JOBSZ *OEFYFE5SFFɺฏߧೋ୳ࡧɺ࠲ඪѹॖɺLEɺ6OJPO'JOEɺಈత࠷దԽɺήʔ Ϝཧɺ࠷૿Ճ෦ྻɺ८ճηʔϧεϚϯɺ࠷খแؚٿɺزԿɺ࠷খॏΈࡾ֯ ܗׂɺάϥϑཧɺ࠷ܦ࿏ɺɺ-PXFTU$PNNPO"ODFTUPSɺϚονϯάɺ ด࿏ݕग़ɺ࠼৭ɺ-PXMJOLɺ࠷খશҬɺτϙϩδΧϧιʔτɺڧ࿈݁ղɺ ᩦཉ๏ɺઢܗɺΨεͷফڈ๏ɺɺೋ߲ɺ($%-$.ɺૉҼղɺ ղੳɺೋ๏ɺϥάϥϯδϡิؒɺιʔτɺసɺ.BOBDIFSɺ.PSSJTr1SBUUɺ ϩʔϦϯάϋογϡɺ4V⒏Y"SSBZɺ;"MHPSJUINɺ͠Ό͘ͱΓ๏ɺ ͜ΕΒ
Ұྫ Λཧղˍ͑ΔΑ͏ʹͳΔ
ૣͬͯΈΔ 3VTUͰʂ
"#$"1SPEVDU IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@B
"#$"1SPEVDU wਖ਼B C͕ඪ४ೖྗ͔Β༩͑ΒΕΔ wۭന۠Γ wB C͕ۮͳΒ&WFOΛحͳΒ0EEΛग़ྗ wB C ֓ཁ
wඪ४ೖྗΛ͏VTFTUEJP wۮ͔Ͳ͏͔JG B C ϙΠϯτ "#$"1SPEVDU w
IUUQTBUDPEFSKQDPOUFTUTBCDTVCNJTTJPOT ղྫ
"#$"1SPEVDUղྫ
"#$"1SPEVDUղྫ ೖྗΛָʹ͍ͨ͠ʂ
ۭനɾվߦ͝ͱʹೖྗΛಘΔؔ
ۭനɾվߦ͝ͱʹೖྗΛಘΔؔ w 3VTUͰڝٕϓϩάϥϛϯάͷೖྗΛεοΩϦهड़͢ΔϚΫϩ2JJUB CZͨͳ͜;͞Μ w IUUQTRJJUBDPNUBOBLIJUFNTCBDDBDEEBD ߋʹߴػೳͳೖྗิॿ Θ͔Γ͍͢
"#$"1BSLJOH IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@B
"#$"1SPEVDU wறंͷྉۚϓϥϯ͕छྨ wϓϥϯ5࣌ؒͰ" 5ԁ wϓϥϯ#ԁݻఆ wਖ਼/ " #͕༩͑ΒΕΔ w/࣌ؒறं͢Δͱ͖ͷ࠷҆ͷஈʁ
֓ཁ
wNJOؔVTFTUEDNQNJO wNJO B C ϙΠϯτ "#$"1SPEVDU
දతίϯςεταΠτ AtCoder Codeforces Google Code Jam ։࠵ස 1,2ճ/ि 6ճ͘Β͍/݄ 1ճ/
ࢀՃਓ/ճ 5000ਓ 10000ਓ 35000ਓ ։࠵ࠃ ຊ ϩγΞ - จ ຊޠ / ӳޠ ӳޠ ӳޠ Rust version 1.15.1 1.35.0 ະରԠ
Ϩϕϧ 100 ࢛ଇԋࢉ, จࣈྻૢ࡞ 200 ݅ذ, ϧʔϓ 300
ιʔτͳͲͷΞϧΰϦζϜͷ͕ࣝඞཁʹ 400 ~ ܭࢉྔͷݟੵΓ͕ඞཁʹ 2000Ҏ্ͷ
"#$# IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@C
"#$# wਖ਼B C͕ඪ४ೖྗ͔Β༩͑ΒΕΔ wۭന۠Γ wBͱCΛจࣈྻͱͯ͠ܨ͛ͨͱ͖ฏํ͔ʁ wྫlz? wฏํͳΒ:FTɺͦ͏Ͱͳ͍ͳΒ/PΛग़ྗ wB C
֓ཁ
wจࣈྻ݁߹GPSNBU l\^\^z B C w4USJOHUPJTJ[FTQBSTFJTJ[F VOXSBQ ϙΠϯτ "#$#
w YBͱCΛ݁߹ͨ͠ w JdY·ͰJ JYΛຬͨ͢ͷ͕ଘࡏ͢Δ͔ௐΔ w ଘࡏ͢ΔͳΒYฏํ ղྫ
"#$#ղྫ ͜ͷղ๏ͷܭࢉྔ0 Y ߋʹྑ͍ղ๏ ɾJd㲋YͰ୳ࡧ0 㲋Y ɾJʹ͍ͭͯೋ୳ࡧ0 MPHY
ܭࢉྔ ྫ 1ඵҎͰ O(1) ࢛ଇԋࢉͳͲ - O(n) n=10^8·Ͱ O(n^2) n=10^4·Ͱ
O(log n) ೋ୳ࡧͳͲ ͨ͘͞Μ O(n log n) ιʔτͳͲ n=10^5·Ͱ ܭࢉྔ w0 O Oճܭࢉ͢ΔͳΒ0 O wఆഒແࢹOճܭࢉ͢Δͱͯ͠0 O #JH0ه๏
"#$#7BSJFE IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@C
"#$#7BSJFE wӳখจࣈ͔ΒͳΔจࣈྻ4͕༩͑ΒΕΔ w4ʹؚ·ΕΔจࣈ͕શͯҟͳΔ͔Ͳ͏͔ wҟͳΔͳΒZFTɺͦ͏Ͱͳ͍ͳΒOPΛग़ྗ w4ͷ͞ ֓ཁ
"#$#7BSJFEղྫ w4USJOHT<J>ͷΑ͏ʹจࣈͷऔಘ͕Ͱ͖ͳ͍ w4USJOH͔Β7FDDIBSʹม͢Δ ϙΠϯτ
"#$$1SJTPO IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@D
"#$$1SJTPO w/ຕͷ*%Χʔυ .ຕͷήʔτ wήʔτ*%ΧʔυͰ௨ΕΔ wJ൪ͷήʔτ-@Jd3@J൪ͷ*%ΧʔυͰ௨ΕΔ wͲΕ͔͍ͭ࣋ͬͯΕ͍͍ wຕ͚ͩͰશήʔτΛ௨աͰ͖Δ*%ΧʔυԿຕ͔ w/? .?
w-@J3@J/ ֓ཁ
4BNQMF ID1 ID2 ID3 ID4 G1 G2 /. -@ 3@
-@ 3@ ൪ͱ൪ͷ*%Χʔυ͕શήʔτΛ௨ΕΔ
4BNQMF ID1 2 3 4 5 6 7 8 9
10 G1 G2 G3 ൪ͷ*%ΧʔυͷΈશήʔτΛ௨ΕΔ
"#$$1SJTPOղྫ
"#$$0UPTIJEBNB IUUQTBUDPEFSKQDPOUFTUTBCDUBTLTBCD@D
"#$$0UPTIJEBNB wԁࡳɺԁࡳɺԁࡳ͕ແݶʹ͋Δ w͓ࡳ͕/ຕɺ߹ܭ:ԁ wԁࡳYຕɺԁࡳZຕɺԁࡳ[ຕͱ͢Δ w༗ΓಘΔຕͷ߹ͤͭΛग़ྗ w:ԁͳΒɺ Y Z [
ͳͲ ֓ཁ
5-&ղ
5-&ղ0 O? O? ?ؒʹ߹Θͳ͍
"$ղ0 O?
·ͱΊ
·ͱΊ wѹతΞτϓοτ͕Ͱ͖Δ wܭࢉྔ͕ݟੵΕΔΑ͏ʹͳΔ wΞϧΰϦζϜͱσʔλߏʹৄ͘͠ͳΕΔ w࣮ྗ͕ఆྔԽ͞ΕΔ wԿΑΓָ͍͠ w࣮ߦʹ͔͔Δॲཧ͕ඵͰͰ͖ͨΓ wʹʹίʔσΟϯάεϐʔυ͕͘ͳͬͨΓ
͓·͚ʢPKʹΑΔࣗಈఏग़ʣ IUUQTHJUIVCDPNNJOBNJOBPBUDPEFSSVTUCMPCNBTUFSWTDPEFUBTLTKTPO IUUQTHJUIVCDPNLNZLPOMJOFKVEHFUPPMT