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

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

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

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