SlideShare a Scribd company logo
1 of 21
Download to read offline
ACM ICPC 2014{2015 
Northeastern European Regional Contest 
Problems Review 
Roman Elizarov 
December 7, 2014
Problem A. Alter Board 
I The minimal answer to this problem is bn=2c + bm=2c 
I The solution is to make inversions on each even row and each 
even column 
I To prove that the answer is minimal consider the
rst column 
with its n cells that form n  1 neighbouring pairs 
I to turn all cells of the
rst column in the same color inversions 
must span the
rst column 
I each spanning inversion makes at most two neighbouring pairs 
of the same color 
I so the minimum of d(n  1)=2e = bn=2c inversions are needed 
I Then consider the top row in the same way
Problem B. Burrito King 
I Consider the problem as a sum of vectors in (a; b) coordinates 
I The resulting vector may not go above b = B line and must 
extend on a axis as far as possible 
I It is optimal to greedily add (ai ; bi ) ingredient vectors starting 
from the ones that have the least angle to 0a line (or maximal 
ai=bi ), until b = B line is crossed 
I Be careful about corner cases with ai = 0 and/or bi = 0 
a 
b 
B 
0 A
Problem C. Cactus Generator 
I This is a straightforward problem for parsing and OO design 
I De
ne class for graph with a method to generate graph given 
index of the
rst and the vertices 
I De
ne class for various range types 
I Parse and construct classes tree 
I Build the resulting graph 
I Connect arbitrary pairs of vertices of odd degree in the 
resulting graph using temporary edges 
I Use classical algorithm for Eulerian path 
I Remove temporary edges to get the minimal number of 
covering paths
Problem D. Damage Assessment 
I Numerically integrate the square section by dx 
I The square of the cut at a given x coordinate is a simple 
planar geometry problem 
I Take care about leftmost point with in
nite derivative 
I however, the required precision does not make this a big 
problem 
I the square section at this point is small 
x
Problem E. Epic Win! 
I There is a simple solution with up to n2 states 
I Build your FSM as n copies of a winning FSM with n states 
I Each state of a winning FSM corresponds to a state in the 
opponent FSM 
I Each move of a winning FSM is a winning move for the 
corresponding opponent's move 
I Next state in a winning FSM corresponds to the opponent 
move and opponent's next state 
I Leave other transitions unde
ned 
I The
rst copy of a winning FMS starts in its
rst state and 
wins an opponent that stats in it
rst state by construction 
I Model the behaviour of the opponent and your FSM for all 
opponent start states from the states 2 to n 
I When a yet unde
ned transition is reached, then insert a 
transition to a fresh copy of a winning FSM into the state 
corresponding to the opponent's, thus ensuring win in this copy 
I Stop modelling when loop is detected 
I Loop is inside one copy of a winning FSM and is always 
winning by construction
Problem F. Filter 
I Nothing fancy here 
I Just implement what the problem statement asks for in a 
straightforward way 
I The hardest part seems to be reading and understanding the 
problem statement
Problem G. Gomoku 
I The
rst player's strategy has pretty strict priorities in the 
moves it makes and it can be exploited 
I Make the

More Related Content

What's hot

How to use STL creator
How to use STL creatorHow to use STL creator
How to use STL creatorRyotaMaeda
 
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...Ceni Babaoglu, PhD
 
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION ppt
Calculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION pptCalculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION ppt
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION pptDrazzer_Dhruv
 
A short proof of konigs matching theorem
A short proof of konigs matching theoremA short proof of konigs matching theorem
A short proof of konigs matching theorem政謙 陳
 
Modern block cipher
Modern block cipherModern block cipher
Modern block cipherUdit Mishra
 
Solution manual for theory and applications of digital speech processing lawr...
Solution manual for theory and applications of digital speech processing lawr...Solution manual for theory and applications of digital speech processing lawr...
Solution manual for theory and applications of digital speech processing lawr...zammok
 
Modified booth's algorithm Part 2
Modified booth's algorithm Part 2Modified booth's algorithm Part 2
Modified booth's algorithm Part 2babuece
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structurehamza javed
 
Overlapping clusters for distributed computation
Overlapping clusters for distributed computationOverlapping clusters for distributed computation
Overlapping clusters for distributed computationDavid Gleich
 

What's hot (20)

How to use STL creator
How to use STL creatorHow to use STL creator
How to use STL creator
 
Digital Logic
Digital LogicDigital Logic
Digital Logic
 
C++11
C++11C++11
C++11
 
Graph theory
Graph theoryGraph theory
Graph theory
 
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
4. Linear Algebra for Machine Learning: Eigenvalues, Eigenvectors and Diagona...
 
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION ppt
Calculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION pptCalculas IMPROPER  INTEGRALS AND  APPLICATION  OF INTEGRATION ppt
Calculas IMPROPER INTEGRALS AND APPLICATION OF INTEGRATION ppt
 
A short proof of konigs matching theorem
A short proof of konigs matching theoremA short proof of konigs matching theorem
A short proof of konigs matching theorem
 
Modern block cipher
Modern block cipherModern block cipher
Modern block cipher
 
Solution manual for theory and applications of digital speech processing lawr...
Solution manual for theory and applications of digital speech processing lawr...Solution manual for theory and applications of digital speech processing lawr...
Solution manual for theory and applications of digital speech processing lawr...
 
Simultaneous equations (2)
Simultaneous equations (2)Simultaneous equations (2)
Simultaneous equations (2)
 
Modified booth's algorithm Part 2
Modified booth's algorithm Part 2Modified booth's algorithm Part 2
Modified booth's algorithm Part 2
 
Graphs in data structure
Graphs in data structureGraphs in data structure
Graphs in data structure
 
Finite fields
Finite fields Finite fields
Finite fields
 
Data Flow Modeling
Data Flow ModelingData Flow Modeling
Data Flow Modeling
 
Overlapping clusters for distributed computation
Overlapping clusters for distributed computationOverlapping clusters for distributed computation
Overlapping clusters for distributed computation
 
Graph
GraphGraph
Graph
 
Matlab Script - Loop Control
Matlab Script - Loop ControlMatlab Script - Loop Control
Matlab Script - Loop Control
 
Ch3
Ch3Ch3
Ch3
 
Chapter 1
Chapter   1Chapter   1
Chapter 1
 
A technical writing on cryptographic hash function md5
A technical writing on cryptographic hash function md5A technical writing on cryptographic hash function md5
A technical writing on cryptographic hash function md5
 

Viewers also liked

ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?Roman Elizarov
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Roman Elizarov
 
Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Roman Elizarov
 
Многопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаМногопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаRoman Elizarov
 
Пишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхПишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхRoman Elizarov
 
The theory of concurrent programming for a seasoned programmer
The theory of concurrent programming for a seasoned programmerThe theory of concurrent programming for a seasoned programmer
The theory of concurrent programming for a seasoned programmerRoman Elizarov
 
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Roman Elizarov
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewRoman Elizarov
 
MIPT Fall Programming Training
MIPT Fall Programming TrainingMIPT Fall Programming Training
MIPT Fall Programming TrainingSolodkova
 
11 x1 t14 06 sum of a geometric series (2012)
11 x1 t14 06 sum of a geometric series (2012)11 x1 t14 06 sum of a geometric series (2012)
11 x1 t14 06 sum of a geometric series (2012)Nigel Simmons
 
13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sumshisema01
 
Problem solving on acm international collegiate programming contest
Problem solving on acm international collegiate programming contestProblem solving on acm international collegiate programming contest
Problem solving on acm international collegiate programming contestFedor Tsarev
 
05 динамическое программирование
05 динамическое программирование05 динамическое программирование
05 динамическое программированиеFedor Tsarev
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search TechniquesShakil Ahmed
 
20130420 bitbyte
20130420 bitbyte20130420 bitbyte
20130420 bitbyteDevexperts
 
Codefreeze rus
Codefreeze rusCodefreeze rus
Codefreeze rusDevexperts
 
How to improve java performance
How to improve java performanceHow to improve java performance
How to improve java performanceDevexperts
 

Viewers also liked (20)

ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
 
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
 
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2016 NEERC (Northeastern European Regional Contest) Problems Review
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
Wait for your fortune without Blocking!
Wait for your fortune without Blocking!Wait for your fortune without Blocking!
Wait for your fortune without Blocking!
 
Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)Многопоточные Алгоритмы (для BitByte 2014)
Многопоточные Алгоритмы (для BitByte 2014)
 
Многопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаМногопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и Практика
 
Пишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхПишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данных
 
The theory of concurrent programming for a seasoned programmer
The theory of concurrent programming for a seasoned programmerThe theory of concurrent programming for a seasoned programmer
The theory of concurrent programming for a seasoned programmer
 
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
 
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
 
MIPT Fall Programming Training
MIPT Fall Programming TrainingMIPT Fall Programming Training
MIPT Fall Programming Training
 
11 x1 t14 06 sum of a geometric series (2012)
11 x1 t14 06 sum of a geometric series (2012)11 x1 t14 06 sum of a geometric series (2012)
11 x1 t14 06 sum of a geometric series (2012)
 
13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums13 3 arithmetic and geometric series and their sums
13 3 arithmetic and geometric series and their sums
 
Problem solving on acm international collegiate programming contest
Problem solving on acm international collegiate programming contestProblem solving on acm international collegiate programming contest
Problem solving on acm international collegiate programming contest
 
05 динамическое программирование
05 динамическое программирование05 динамическое программирование
05 динамическое программирование
 
Advanced Search Techniques
Advanced Search TechniquesAdvanced Search Techniques
Advanced Search Techniques
 
20130420 bitbyte
20130420 bitbyte20130420 bitbyte
20130420 bitbyte
 
Codefreeze rus
Codefreeze rusCodefreeze rus
Codefreeze rus
 
How to improve java performance
How to improve java performanceHow to improve java performance
How to improve java performance
 

Similar to ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review

Engineering garphics projection of solids
Engineering garphics   projection of solidsEngineering garphics   projection of solids
Engineering garphics projection of solidsPranav Kulshrestha
 
Projection of solids
Projection of solidsProjection of solids
Projection of solidsAbhay Jain
 
Projectionofsolids 120517063655-phpapp01
Projectionofsolids 120517063655-phpapp01Projectionofsolids 120517063655-phpapp01
Projectionofsolids 120517063655-phpapp01bjslides
 
Projection of solids
Projection of solidsProjection of solids
Projection of solidsgtuautonomous
 
Projectionofsolids(thedirectdata[1].com)
Projectionofsolids(thedirectdata[1].com)Projectionofsolids(thedirectdata[1].com)
Projectionofsolids(thedirectdata[1].com)Ravi Patel
 
5 projection of solids
5 projection of solids5 projection of solids
5 projection of solidsShaman Gupta
 
Projection of solids(thedirectdata.com)
Projection of solids(thedirectdata.com)Projection of solids(thedirectdata.com)
Projection of solids(thedirectdata.com)India
 
UNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptUNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptVijayalakshmiR64
 
surface development.ppt
surface development.pptsurface development.ppt
surface development.pptssuser6cdd2d
 
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.pptReifalynFulig
 
UNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptUNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptVijayalakshmiR64
 
Projection of planes revised
Projection of planes revisedProjection of planes revised
Projection of planes revisedManoranjan Kumar
 
sum of interior and exterior angles in polygons
   sum of interior and exterior angles in polygons   sum of interior and exterior angles in polygons
sum of interior and exterior angles in polygonsAneesha Jesmin
 

Similar to ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review (20)

Engineering garphics projection of solids
Engineering garphics   projection of solidsEngineering garphics   projection of solids
Engineering garphics projection of solids
 
Projection of Solids
Projection of SolidsProjection of Solids
Projection of Solids
 
Projection of solids
Projection of solidsProjection of solids
Projection of solids
 
Projectionofsolids 120517063655-phpapp01
Projectionofsolids 120517063655-phpapp01Projectionofsolids 120517063655-phpapp01
Projectionofsolids 120517063655-phpapp01
 
Projection of solids
Projection of solidsProjection of solids
Projection of solids
 
Projectionofsolids(thedirectdata[1].com)
Projectionofsolids(thedirectdata[1].com)Projectionofsolids(thedirectdata[1].com)
Projectionofsolids(thedirectdata[1].com)
 
5 projection of solids
5 projection of solids5 projection of solids
5 projection of solids
 
Projection of solids(thedirectdata.com)
Projection of solids(thedirectdata.com)Projection of solids(thedirectdata.com)
Projection of solids(thedirectdata.com)
 
UNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptUNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.ppt
 
6. Projection of solids.ppt
6. Projection of solids.ppt6. Projection of solids.ppt
6. Projection of solids.ppt
 
Unit -4.pptx
Unit -4.pptxUnit -4.pptx
Unit -4.pptx
 
surface development.ppt
surface development.pptsurface development.ppt
surface development.ppt
 
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt
1mm1g3a-sumofinteriorandexterioranglesinpolygons-170218173450.ppt
 
UNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.pptUNIT-3 PROJECTION OF SOLIDS.ppt
UNIT-3 PROJECTION OF SOLIDS.ppt
 
projection of solids
projection of solidsprojection of solids
projection of solids
 
Unit 5
Unit 5Unit 5
Unit 5
 
projection of solide
projection of solideprojection of solide
projection of solide
 
Unit 6
Unit 6Unit 6
Unit 6
 
Projection of planes revised
Projection of planes revisedProjection of planes revised
Projection of planes revised
 
sum of interior and exterior angles in polygons
   sum of interior and exterior angles in polygons   sum of interior and exterior angles in polygons
sum of interior and exterior angles in polygons
 

More from Roman Elizarov

Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Roman Elizarov
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Roman Elizarov
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Roman Elizarov
 
Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017Roman Elizarov
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneRoman Elizarov
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines ReloadedRoman Elizarov
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesRoman Elizarov
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutinesRoman Elizarov
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waitingRoman Elizarov
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and FallaciesRoman Elizarov
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure javaRoman Elizarov
 

More from Roman Elizarov (12)

Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018Kotlin Coroutines in Practice @ KotlinConf 2018
Kotlin Coroutines in Practice @ KotlinConf 2018
 
Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017Deep dive into Coroutines on JVM @ KotlinConf 2017
Deep dive into Coroutines on JVM @ KotlinConf 2017
 
Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017Introduction to Coroutines @ KotlinConf 2017
Introduction to Coroutines @ KotlinConf 2017
 
Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017Fresh Async with Kotlin @ QConSF 2017
Fresh Async with Kotlin @ QConSF 2017
 
Scale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOneScale Up with Lock-Free Algorithms @ JavaOne
Scale Up with Lock-Free Algorithms @ JavaOne
 
Kotlin Coroutines Reloaded
Kotlin Coroutines ReloadedKotlin Coroutines Reloaded
Kotlin Coroutines Reloaded
 
Lock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin CoroutinesLock-free algorithms for Kotlin Coroutines
Lock-free algorithms for Kotlin Coroutines
 
Introduction to Kotlin coroutines
Introduction to Kotlin coroutinesIntroduction to Kotlin coroutines
Introduction to Kotlin coroutines
 
Non blocking programming and waiting
Non blocking programming and waitingNon blocking programming and waiting
Non blocking programming and waiting
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
Java Serialization Facts and Fallacies
Java Serialization Facts and FallaciesJava Serialization Facts and Fallacies
Java Serialization Facts and Fallacies
 
Millions quotes per second in pure java
Millions quotes per second in pure javaMillions quotes per second in pure java
Millions quotes per second in pure java
 

Recently uploaded

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review

  • 1. ACM ICPC 2014{2015 Northeastern European Regional Contest Problems Review Roman Elizarov December 7, 2014
  • 2. Problem A. Alter Board I The minimal answer to this problem is bn=2c + bm=2c I The solution is to make inversions on each even row and each even column I To prove that the answer is minimal consider the
  • 3. rst column with its n cells that form n 1 neighbouring pairs I to turn all cells of the
  • 4. rst column in the same color inversions must span the
  • 5. rst column I each spanning inversion makes at most two neighbouring pairs of the same color I so the minimum of d(n 1)=2e = bn=2c inversions are needed I Then consider the top row in the same way
  • 6. Problem B. Burrito King I Consider the problem as a sum of vectors in (a; b) coordinates I The resulting vector may not go above b = B line and must extend on a axis as far as possible I It is optimal to greedily add (ai ; bi ) ingredient vectors starting from the ones that have the least angle to 0a line (or maximal ai=bi ), until b = B line is crossed I Be careful about corner cases with ai = 0 and/or bi = 0 a b B 0 A
  • 7. Problem C. Cactus Generator I This is a straightforward problem for parsing and OO design I De
  • 8. ne class for graph with a method to generate graph given index of the
  • 9. rst and the vertices I De
  • 10. ne class for various range types I Parse and construct classes tree I Build the resulting graph I Connect arbitrary pairs of vertices of odd degree in the resulting graph using temporary edges I Use classical algorithm for Eulerian path I Remove temporary edges to get the minimal number of covering paths
  • 11. Problem D. Damage Assessment I Numerically integrate the square section by dx I The square of the cut at a given x coordinate is a simple planar geometry problem I Take care about leftmost point with in
  • 12. nite derivative I however, the required precision does not make this a big problem I the square section at this point is small x
  • 13. Problem E. Epic Win! I There is a simple solution with up to n2 states I Build your FSM as n copies of a winning FSM with n states I Each state of a winning FSM corresponds to a state in the opponent FSM I Each move of a winning FSM is a winning move for the corresponding opponent's move I Next state in a winning FSM corresponds to the opponent move and opponent's next state I Leave other transitions unde
  • 15. rst copy of a winning FMS starts in its
  • 16. rst state and wins an opponent that stats in it
  • 17. rst state by construction I Model the behaviour of the opponent and your FSM for all opponent start states from the states 2 to n I When a yet unde
  • 18. ned transition is reached, then insert a transition to a fresh copy of a winning FSM into the state corresponding to the opponent's, thus ensuring win in this copy I Stop modelling when loop is detected I Loop is inside one copy of a winning FSM and is always winning by construction
  • 19. Problem F. Filter I Nothing fancy here I Just implement what the problem statement asks for in a straightforward way I The hardest part seems to be reading and understanding the problem statement
  • 21. rst player's strategy has pretty strict priorities in the moves it makes and it can be exploited I Make the
  • 22. rst move into the free space of the board 2 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 23. Problem G. Gomoku cont'd I The opponent must play around the center and you form a diagonal 2 4 3 1 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 24. Problem G. Gomoku cont'd I The opponent forms three in a row and you make defensive moves 2 4 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 25. Problem G. Gomoku cont'd I The opponent closes two in a row at one side, and you extend in on the other 10 2 4 9 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 26. Problem G. Gomoku cont'd I The opponent closes the three on the other side, but you continue oence at building a winning position 11 10 2 4 12 9 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 27. Problem G. Gomoku cont'd I Force the opponent into a sequence of defensive moves I Then close four in a row with a hole that is formed by the opponent defence 15 11 14 18 10 19 2 20 4 16 12 17 9 13 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 28. Problem G. Gomoku cont'd I The opponent closes your open three, you extend it, forming a winning fork 15 22 11 14 18 10 19 2 20 4 16 12 17 9 21 13 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 29. Problem G. Gomoku win I You win I It is very hard to win otherwise, because playing
  • 30. rst in gomoku gives an enormous advantage even to such a simple strategy 26 23 15 22 11 14 18 10 19 2 20 4 16 12 17 24 9 21 13 25 6 3 1 5 7 8 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19
  • 31. Problem H. Hidden Maze I Make a rooted tree I Lets compute how many times each edge is a median I Start with an edge with lowest ci and work in increasing order of ci I For each edge ci look at its lowest vertex j in the tree I For each path from j down into the subtree, let the balance be the number of edges with c higher than current ci minus the number of edges with c lower than current ci I For each vertex j maintain an array bj I with 2dj + 1 elements bj [] for jj di , where dj is a depth of subtree rooted at j I each item bj [] contains a number of paths down from j with a balance I including an empty path with balance zero
  • 32. Problem H. Hidden Maze cont'd I Initial bj [] is the number of paths of a length down from vertex j P I It is easy to compute recursively in O( dj ) while building rooted tree I From the current vertex j walk up the tree I For all vertices k up tree from j compute the number of paths with balance zero going from down up to j , then up to k then down to other subtree of k I paths with zero balance are the ones where ci is the median X =dj :::dj bj [] (bk [ k;j] bk#[ k;j k;k#]) I where k # is the next vertex from k down on the path to j and j is the next vertex up from j I and k;j is the sum of balances on a path from k to j I The total complexity is O( P dj hj ), where hj is the height of vertex j | length of path from root
  • 33. Problem H. Hidden Maze cont'd I Update bj [] when done with an edge ci I For all vertices k up tree from j update the bk arrow taking into account that ci balance changes from 1 to 1 bk [] bk [] + bj [ k;j + 1] bj [ k;j 1] I The total complexity is also O( P dj hj ) I However, for the graph randomly generated as described in the problem statement P (dj hj ) = O(n p n)
  • 34. Problem I. Improvements I Consider transposition aj | the number of ship at coordinate j , that is reverse to what is given in the input I It is easy to prove that the chain of ships that remain on their initial position corresponds to a subsequence of aj with a special property: I it is an increasing sequence of numbers aj followed by decreasing sequence of numbers aj I Increasing/decreasing subsequence is a well-known problem with O(n log n) solution using dynamic programming 0 0 1 1 3 2 4 3 2 4
  • 35. Problem J. Jokewithpermutation I This problem is solved with exhaustive search I for each number try all positions that it can occupy I start search with numbers that can occupy fewest number of possible positions
  • 36. Problem K. Knockout Racing I Nothing fancy here I Just implement what the problem statement asks for in a straightforward way I This is the easiest problem in the contest