Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Educational Codeforces Round 54 E. Vasya and a ...
Search
betrue12
November 13, 2018
Programming
2.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Educational Codeforces Round 54 E. Vasya and a Tree
ブログ解説用
betrue12
November 13, 2018
Other Decks in Programming
See All in Programming
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
390
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.1k
Domain-Driven Transformation
hschwentner
2
2.3k
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
270
sbt 2.0: takeoff
eed3si9n
0
160
JIS keyboard support in Omarchy
lef237
0
110
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Unity6 URPによる海底をテーマにしたVJシステムの解説 | Unity Shader 完全に理解した 勉強会
gam0022
0
370
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
Featured
See All Featured
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
570
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
310
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
Tell your own story through comics
letsgokoyo
1
1.1k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
620
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
RailsConf 2023
tenderlove
30
1.6k
Transcript
1 2 3 4 5 6 図のようなグラフにおいて、クエリとして v = 3,
d = 1, x = 5 の1つだけを考える。 これは図の橙色の範囲になる。
1 2 3 4 5 6 sum = 0 ans[1]
= 0 頂点1からDFSする。 sumは各頂点の値を差分更新するための値。 imos配列はimos法のように 「範囲から(下側に)出る」という処理を するための配列。 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 0 0 0
1 2 3 4 5 6 sum = 5 (+5)
ans[3] = 5 頂点3を訪れる。 上からの遷移でクエリの頂点 vに入った時、 imos配列に以下のような加算を行う。 (普通のimos法と同じような加算) ・vの深さに、そのクエリの加算値 xを足す。 ・「範囲から出る」深さの imos配列に -xを加算する。 その後、imos配列の値をsumに足す。 0 0 → 5 0 0 → -5 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5
1 2 3 4 5 6 sum = 5 ans[5]
= 5 頂点5を訪れる。 0 5 0 -5 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5
1 2 3 4 5 6 sum = 0 (-5)
ans[6] = 0 頂点6を訪れる。 範囲から出るので、sumから値を 引かなければならない。 このとき、imos配列の値を加算することで 「範囲から出る」処理を実現できる。 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 0 -5
1 2 3 4 5 6 sum = 5 (+5)
頂点5に戻る。 上に戻る際は、imos配列の値を引く。 (再びクエリの範囲内に入る) 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 0 -5
1 2 3 4 5 6 sum = 5 頂点3に戻る。
深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 0 -5
1 2 3 4 5 6 sum = 5 ans[4]
= 5 頂点4を訪れる。 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 0 -5
1 2 3 4 5 6 sum = 5 頂点3に戻る。
深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 0 -5
1 2 3 4 5 6 sum = 0 (-5)
頂点1に戻る。 このとき、入るときとは逆に まずsumからimos配列の値を引く。 その後、もうこのクエリの範囲には入らないので imos配列に足していた値を消す。 ※この後、頂点2を訪れる、頂点1に戻る、と続く (省略) 深さに対応した imos配列 クエリ v = 3, d = 1, x = 5 0 5 → 0 0 -5 → 0
1 2 3 4 5 6 深さに対応した imos配列 ※imos配列を使うと何が嬉しい? 1つのクエリだけだと実感できないが、
実際の問題はこんな感じで クエリが重なって入り組んでいる 「たくさんの区間をまとめて処理できる」 通常のimos法と同じように、 imos配列を使うとこれらのクエリを 同時並行的にまとめて処理できる 0 0 0 0