SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
ACM ICPC 2015–2016
Northeastern European Regional Contest
Problems Review
Roman Elizarov
December 6, 2015
Problems summary
Recap: 224 teams, 12 problems, 5 hours,
20-th NEERC — Jubilee
This review assumes the knowledge of the problem statements
(published separately on http://neerc.ifmo.ru/ web site)
Summary table on the next slide lists problem name and stats
author — author of the original idea
acc — number of teams that had solved the problem (gray bar
denotes a fraction of the teams that solved the problem)
runs — number of total attempts
succ — overall successful attempts rate (percent of accepted
submissions to total, also shown as a bar)
Problems summary (2)
problem name author acc/runs succ
Adjustment Office Vitaliy Aksenov 196 /522 37%
Binary vs Decimal Mikhail Tikhomirov 12 /83 14%
Cactus Jubilee Mikhail Tikhomirov 14 /28 50%
Distance on Triangulation Gennady Korotkevich 9 /67 13%
Easy Problemset Andrey Lopatin 208 /281 74%
Froggy Ford Georgiy Korneev 101 /602 16%
Generators Elena Andreeva 153 /533 28%
Hypercube Oleg Khristenko 3 /15 20%
Iceberg Orders Egor Kulikov 0 /2 0%
Jump Maxim Buzdalov 52 /577 9%
King’s Inspection Mikhail Dvorkin 24 /253 9%
Landscape Improved Georgiy Korneev 56 /213 26%
Problem A. Adjustment Office
Total
time
0h 1h 2h 3h 4h 5h
196
326
Java C++ Total
Accepted 17 179 196
Rejected 53 273 326
Total 70 452 522
solution team att time size lang
Fastest SPbAU 1 1 7 1,051 C++
Shortest NU 14 2 41 529 C++
Max atts. UrSU 2 10 130 1,650 Java
Problem A. Adjustment Office (1)
Recap: n × n grid, each cell (x, y) has value x + y
Initial sum at row or column k is equal to nk + n(n+1)
2
Maintain two pieces of data for rows and columns:
The set of all zeroed out rows Sr and columns Sc, initially
both sets are empty
Two sums sr,c = i∈{1...n}Sr,c
i, initially both sums are n(n+1)
2
The result of row query “R r” is equal to:
n −|Sc| r + sc if r /∈ Sr
0 otherwise
If r /∈ Sr, then Sr ← Sr ∪ {r} and sr ← sr − r
Similarly for column queries
Problem B. Binary vs Decimal
Total
time
0h 1h 2h 3h 4h 5h
12
71
Java C++ Total
Accepted 4 8 12
Rejected 4 67 71
Total 8 75 83
solution team att time size lang
Fastest SPb SU 1 2 73 1,914 Java
Shortest ITMO 1 1 112 1,193 Java
Max atts. MAI 5 269 256,031 C++
Problem B. Binary vs Decimal (1)
It is easy to prove that 10k
2 has 2k
2 as a suffix, for example:
decimal binary
110 12
1010 10102
10010 11001002
100010 11111010002
Let Ck be a set of all numbers less than 10k, whose decimal
representation is equal to its k last binary digits
Let Ck = Ak ∪ Bk, where all x ∈ Ak have k-th (counting from
zero) digit of 0 and all x ∈ Bk have k-th digit of 1
Bk is a set of bindecimal numbers of length k — one we want
k Ak Bk
0 {0} {}
1 {0} {1}
2 {0, 1} {10, 11}
3 {0, 1, 10, 11} {100, 101, 110, 111}
4 {0, 1, 100, 101} {1000, 1001, 1100, 1101}
Problem B. Binary vs Decimal (2)
Define a recursive rule to get Ck from Ck−1
Ak = x x ∈ Ck−1 and k-th bit of x is zero
Bk = x + 10k
x ∈ Ck−1 and k-th bit of x is zero
Ck = Ak ∪ Bk
Keep Ck as an ordered list, so when new Bk is computed as
defined above, the bindecimal numbers in Bk are produced in
ascending order; count them; stop when n-th bindecimal
number is found
Note, that the max answer for n = 10 000 is around 10161, so
it will not fit into any standard data types; need long
arithmetics to implement it
Problem C. Cactus Jubilee
Total
time
0h 1h 2h 3h 4h 5h
14
14
Java C++ Total
Accepted 0 14 14
Rejected 0 14 14
Total 0 28 28
solution team att time size lang
Fastest Saratov SU 4 1 124 3,673 C++
Shortest Ural FU 1 2 151 2,735 C++
Max atts. MIPT 2 4 279 3,487 C++
Problem C. Cactus Jubilee (1)
Depth-first search (DFS) of the cactus to split the edges of
the cactus into disjoint sets of bridge-trees Bi and cycles Ci
Each back edge found during DFS signals a cycle
Compute size of each Bi and a number of non-adjacent pairs
of edges during the first DFS; do a second DFS to push it to
all adjacent cycles
1
2
3
4
5
6
7
8
9
10 11
1213
14
15
C1
C2
C3
C4
B1
Problem C. Cactus Jubilee (2)
When an edge from a bridge-tree Bi is removed, cactus splits
into two connected components
any pair of vertices from these two components can be
reconnected to get a cactus
number of ways can be counted during initial DFS
1
2
3
4
5
6
7
8
9
10 11
1213
14
15
Problem C. Cactus Jubilee (3)
When an edge from a cycle Ci is removed, cactus is still
connected; bridge-trees adjacent to cycle merge
any pair of non-adjacent vertices from the same bridge-tree
can be connected to get a cactus
Scan all cycles to figure out the the number of ways to add an
edge for each cycle broken; multiple by the cycle size
1
2
3
4
5
6
7
8
9
10 11
1213
14
15
Problem D. Distance on Triangulation
Total
time
0h 1h 2h 3h 4h 5h
9
58
Java C++ Total
Accepted 0 9 9
Rejected 2 56 58
Total 2 65 67
solution team att time size lang
Fastest NNSU 1 145 4,602 C++
Shortest SPbAU 1 1 235 3,579 C++
Max atts. SPb SU 3 6 266 7,846 C++
Problem D. Distance on Triangulation (1)
Divide and conquer; prove that each triangulated polygon has
a diagonal that cuts at least n/3 vertices
Randomly picking a diagonal does not work — will time limit
Recursively split polygons this way for a total depth of
O(log n); get O(n) subpolygons of total size O(n log n)
Terminal subpolygons for this problem are the ones that do
not have have any diagonals to split them further — triangles
1 2
3
45
6
Problem D. Distance on Triangulation (2)
For each subpolygon precompute the shortest distances from
two ends of the diagonals of that was used to cut out this
subpolygon from the large one
O(n log n) total memory to store the distances
Can be done in O(n log n) by doing breadth-first search in each
subpolygon or in O(n log2
n) by doing recursive queries (see
below for query implementation)
Each query can be answered in O(log n) recursively
Terminal subpolygon (triangle) — trivial
x and y in query are both on one side of splitting diagonal —
recursive query into the corresponding subpolygon
x and y in query are on different sides — use precomputed
distances to diagonal ends (diagonals do not intersect, so
x − y path goes through one of the ends)
Problem E. Easy Problemset
Total
time
0h 1h 2h 3h 4h 5h
208
73
Java C++ Total
Accepted 17 191 208
Rejected 9 64 73
Total 26 255 281
solution team att time size lang
Fastest Ural FU 1 1 8 1,011 C++
Shortest NU 14 1 22 426 C++
Max atts. Kyrgyz-Turkish U 1 5 188 781 C++
Problem E. Easy Problemset (1)
The easiest problem
Just implement what the problem statement says
Pay attention to judges without remaining problems — don’t
forget to propose a hard problem
Sample inputs and outputs were designed to expose all the
tricky cases to make debugging easy
Problem F. Froggy Ford
Total
time
0h 1h 2h 3h 4h 5h
101
501
Java C++ Total
Accepted 5 96 101
Rejected 12 489 501
Total 17 585 602
solution team att time size lang
Fastest NNSU 1 41 2,281 C++
Shortest ITMO 4 1 85 1,600 C++
Max atts. Saratov SU 3 19 217 3,797 C++
Problem F. Froggy Ford (1)
Consider a graph with vertices 1, . . . n corresponding to
stones, 0 for the left shore, n + 1 for the right one; obvious
way to compute distances between vertices
The problem of finding the optimal route from 0 to n + 1 as
defined in problem is called minimax path problem
1
2
3
4
5
6
7
0
8
Problem F. Froggy Ford (2)
Minimax path form 0 to all other vertices can be found by
Djikstra algorithm with a corresponding minimax update rule;
O(n2); no need to even have a heap in Djikstra
Second invocation of the same algo to find minimax path
from n + 1 to all others
A new optimal stone can be only at the center between a pair
of vertices (stone – stone, stone – shore, shore – shore)
Check all pairs of vertices; O(n2
)
Use precomputed distances to 0 and to n + 1 to find distance
when new stone is placed; pick the optimal case
Make sure to correctly implement distances between shores
(vertices 0 and n + 1); this case is not covered in sample input
Problem G. Generators
Total
time
0h 1h 2h 3h 4h 5h
153
380
Java C++ Total
Accepted 9 144 153
Rejected 53 327 380
Total 62 471 533
solution team att time size lang
Fastest MSU 3 1 29 3,169 C++
Shortest Ural FU 4 2 86 1,136 C++
Max atts. Far Eastern FU 19 262 1,699 C++
Problem G. Generators (1)
Recap: x
(j)
i+1 = a(j)x
(j)
i + b(j) mod c(j)
Generate c(j) numbers for each LCG — produce all numbers
this LCG can possibly generate; for each LCG find:
the maximum x
(j)
tj
; pay attention to x
(j)
0 (don’t skip it)
the second maximum x
(j)
uj , such that x
(j)
tj
− x
(j)
uj mod k = 0
Pay attention to cases when there is no second maximum, e.g.
all generated numbers are the same or all differences between
them are multiples of k
When n
j=1 x
(j)
tj
mod k = 0 — that’s the answer
Otherwise, find j such that x
(j)
tj
− x
(j)
uj is maximized (if at
least one second maximum uj exists) and replace tj with uj
Otherwise, there is no answer
Problem H. Hypercube
Total
time
0h 1h 2h 3h 4h 5h
3
12
Java C++ Total
Accepted 0 3 3
Rejected 0 12 12
Total 0 15 15
solution team att time size lang
Fastest SPb SU 1 1 175 2,241 C++
Shortest SPb SU 1 1 175 2,241 C++
Max atts. Ural FU 1 3 289 5,628 C++
Problem H. Hypercube (1)
Disassemble tesseract into 8 cubic cells
Start with an arbitrary cube of an octocube, assume it
corresponds to an arbitrary cell of tesseract
Visit all cubes of a given octocube via DFS
Each time a cube is visited, see what cell it shall correspond
to and if that cell was not used yet
There are two conceptual ways to uniquely identify tesseract’s
cells and to traverse them
3D geometry — represent each cell via numbering of its 8
vertices; no 4D vector manipulations required
4D geomerty — represent each cell via a 4D vector normal;
leads to simpler code
Problem H. Hypercube (2)
Disassembled tesseract with numbered vertices and normals
(-1,0,0,0)
(1,0,0,0)
(0,-1,0,0)
(0,1,0,0)
(0,0,-1,0)
(0,0,1,0)
(0,0,0,-1)
(0,0,0,1)
0
8
4
12
2
10
6
14
1
9
5
13
3
11
7
15
0
8
4
12
1
9
5
13
2
10
6
14
3
11
7
15
0
8
2
10
1
9
3
11
4
12
6
14
5
13
7
15
0
4
2
6
1
5
3
7
8
12
10
14
9
13
11
15
x
y
t
z
Problem H. Hypercube (3)
Solution using 3D geometry
All vertices of a tesseract are numbered from 0 to 15
Cell in a tesseract are represented by cubes of 8 vertex indices
Moving in one of 6 directions in an given octocube, find 4
vertices in that direction on a corresponding face of the
current cube
Among remaining cells find the one that can be
rotated/flipped (in 3D) to get a match of vertices
face-to-face — this is the next cell and its 3D rot’n/flip
0
4
2
6
1
5
3
7
1
5
3
7
9
13
11
15
Problem H. Hypercube (4)
Solution using 4D geometry
Keep track of a 4 × 4D vectors: 3 vectors define a basis for
current cell’s hyperplane, 4th vector defines a normal
A normal also uniquely identifies a cell of a tesseract
Moving in one of 6 directions in an given octocube, the
corresponding basis vector of the current hyperplane
(multiplied by ±1 depending on direction in the axis) becomes
the normal of the next cell; the former normal replaces basis
vector in that direction (multiplied by 1) — proper 4D rot’n
x
y
z
norm (0,0,0,-1)
x (0,0,0,1)
y
z
norm (1,0,0,0)
Problem I. Iceberg Orders
Total
time
0h 1h 2h 3h 4h 5h
2
Java C++ Total
Accepted 0 0 0
Rejected 0 2 2
Total 0 2 2
Problem I. Iceberg Orders (1)
The structure of the code is hinted in the statement:
keep buy and sell orders in the book separately in a sorted tree
maps keyed by the price
at each price keep a list of orders ordered by priority
this way finding a set of orders to match with is efficient —
O(k), where k is the number of orders to match with
The solution is then mostly boils down to implementing what
the problem statement says, with one tricky case
When big order (volume Va is big) comes in, it produces a lot
of trades with other orders that have small tip value TVb;
namely O(Va) trades — too many to simulate directly
Recap: Va is up to 109; while the total number of different
matched order pairs is guaranteed not to exceed 105
Problem I. Iceberg Orders (2)
The tricky case is addressed by figuring out how many times
m an incoming order fully matches with all orders at a current
price level
m is found using binary search in O(p log Va) operations,
where p is the number of orders at a given price level
Then, all the m matches can be simulated at one pass in
O(p); simulating remaining pass directly
Care shall taken be in two additional cases
when p k make sure that O(k) operations are performed —
must do one direct order-by-order match at a given price level
first
when incoming order volume Va is so big that the whole price
level with k orders is consumed, must do it in O(k); can afford
additional log in binary search only at the last matched price
level
Problem J. Jump
Total
time
0h 1h 2h 3h 4h 5h
52
525
Java C++ Total
Accepted 1 51 52
Rejected 43 482 525
Total 44 533 577
solution team att time size lang
Fastest Ural FU 1 1 33 1,401 C++
Shortest Ural FU 4 5 286 905 C++
Max atts. Perm SU 1 7 251 1,323 C++
Problem J. Jump (1)
Recap: must solve in n + 500 queries
Solve the problem in two phases: Phase I with up to 499
queries and Phase II with up to n + 1 queries
Phase I: find QI such that Jump(QI) = n/2
do random queries in this phase
worst case when n = 1000, probability of guessing n/2 bits in a
single random query is
(1000
500 )
21000 = 0.0252 . . .
probability of not finding QI in 499 queries is 2.9 × 10−6
Just quit if Jump(QI) = n is found
Phase II: find solution QII such that Jump(QII) = n
for i = 2 . . . n do queries with Qi ={QI bits 0 and i flipped}
Jump(Qi ) = n/2 if bits 0 and i has the same “correctness”
assume 0 is correct bit in QI; make QII={QI all bits j flipped}
where Jump(Qj ) = n/2; try query QII; quit if got n
assume 0 is not correct; make QII={QI all bits j flipped}
where j = 0 or Jump(Qj ) = n/2; must get Jump(QII) = n
Problem K. King’s Inspection
Total
time
0h 1h 2h 3h 4h 5h
24
229
Java C++ Total
Accepted 0 24 24
Rejected 6 223 229
Total 6 247 253
solution team att time size lang
Fastest MIPT 5 2 102 2,920 C++
Shortest ITMO 1 3 212 2,164 C++
Max atts. NEFU 1 9 279 2,865 C++
Problem K. King’s Inspection (1)
Count in-degree din
i and out-degree dout
i for each city i; there
is no route if either is zero for any city (important check!)
Identify special cites i: capital (i = 1) and cities with din
i > 1
or dout
i > 1; there are at most 41 special cities
Other cities are ordinary
captial (special) 1 2 ordinary
ordinary 3 4 special
Problem K. King’s Inspection (2)
Merge all paths between special cities though ordinary cities.
Ordinary cities: non-capital and din
i = 1 and dout
i = 1
For each special city create a list of outgoing paths to other
special cities
there is no route if more than one outgoing path from a special
city requires going through ordinary cities
if there is one outgoing path through ordinary cities, make it
the only path in the outgoing list
captial (special) 1 2
3 4 special
Problem K. King’s Inspection (3)
The picture shows properly reduced graph; but the list of
cities on the reduced paths is still kept to print the answer
Do exhaustive search (backtracking) for a path — at most 220
operations
There are at most 20 special cities with some choice (more
that 1 outgoing path in list)
captial (special) 1 2
3 4 special
Problem L. Landscape Improved
Total
time
0h 1h 2h 3h 4h 5h
56
157
Java C++ Total
Accepted 2 54 56
Rejected 8 149 157
Total 10 203 213
solution team att time size lang
Fastest Saratov SU 4 1 53 2,969 C++
Shortest Kazakh-British TU 2 5 289 1,465 C++
Max atts. MIPT 3 9 298 2,880 C++
Problem L. Landscape Improved (1)
Do binary search for the answer; try O(log n) guesses at the
answer in the process
For each guess m of the answer count the number of squares
of stones required to build a mountain of height m, if it is
possible; compare the result with n
Let ri be the number of squares of stones required to support
the mountain of height m with a peak at i at the right
i = 2
m = 7 r2 = 9
Problem L. Landscape Improved (2)
Let li — the number to support at the left
Total number of squares ti = li + ri + m − hi
The number of required squares is min ti for all i
ri is computed with a single pass for i from 1 to w in O(w)
li with a single pass for i from w to 1
overall time to find a solution is O(w log n)
i = 2
m = 7
l2 = inf cannot support at the left
Credits
Special thanks to all jury members and assistants
(in alphabetic order):
Alexander Kaluzhin, Andrey Lopatin, Andrey Stankevich,
Artem Vasilyev, Borys Minaiev, Demid Kucherenko,
Dmitry Shtukenberg, Egor Kulikov, Elena Andreeva,
Gennady Korotkevich, Georgiy Korneev, Gleb Evstropov,
Grigoriy Shovkoplyas, Maxim Buzdalov, Mikhail Dvorkin,
Mikhail Pyaderkin, Mikhail Tikhomirov, Nikita Kravtsov,
Niyaz Nigmatullin, Oleg Hristenko, Pavel Krotkov,
Pavel Kunyavsky, Pavel Mavrin, Petr Mitrichev,
Viktor Omelyanenko, Vitaly Aksenov

Más contenido relacionado

Destacado

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
 
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 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
 
MIPT Fall Programming Training
MIPT Fall Programming TrainingMIPT Fall Programming Training
MIPT Fall Programming TrainingSolodkova
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Олег Стрекаловский
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Олег Стрекаловский
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Олег Стрекаловский
 
Louis sullivan
Louis  sullivanLouis  sullivan
Louis sullivanArjun CM
 

Destacado (18)

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
 
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems ReviewACM ICPC 2014 NEERC (Northeastern European Regional Contest) Problems Review
ACM ICPC 2014 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)
 
Многопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и ПрактикаМногопоточное Программирование - Теория и Практика
Многопоточное Программирование - Теория и Практика
 
MIPT Fall Programming Training
MIPT Fall Programming TrainingMIPT Fall Programming Training
MIPT Fall Programming Training
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
 
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...Разбор задач областного этапа всероссийской олимпиады школьников по информати...
Разбор задач областного этапа всероссийской олимпиады школьников по информати...
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Binary tree
Binary treeBinary tree
Binary tree
 
Binary tree
Binary  treeBinary  tree
Binary tree
 
Louis sullivan
Louis  sullivanLouis  sullivan
Louis sullivan
 
False ceiling
False ceilingFalse ceiling
False ceiling
 
Topic 9 finishes
Topic 9   finishesTopic 9   finishes
Topic 9 finishes
 
P 048 Copd
P 048 CopdP 048 Copd
P 048 Copd
 
Fe jeff cw_revised
Fe jeff cw_revisedFe jeff cw_revised
Fe jeff cw_revised
 

Similar a ACM ICPC 2015–2016 Northeastern European Regional Contest Problems Review

SIAM - Minisymposium on Guaranteed numerical algorithms
SIAM - Minisymposium on Guaranteed numerical algorithmsSIAM - Minisymposium on Guaranteed numerical algorithms
SIAM - Minisymposium on Guaranteed numerical algorithmsJagadeeswaran Rathinavel
 
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory Based
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory BasedJEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory Based
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory BasedMiso Study
 
Semet Gecco06
Semet Gecco06Semet Gecco06
Semet Gecco06ysemet
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Saad Liaqat
 
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxjacksnathalie
 
Ece512 h1 20139_621386735458ece512_test2_solutions
Ece512 h1 20139_621386735458ece512_test2_solutionsEce512 h1 20139_621386735458ece512_test2_solutions
Ece512 h1 20139_621386735458ece512_test2_solutionsnadia abd
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanationsGopi Saiteja
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsAjay Bidyarthy
 
4.2 collision detection
4.2 collision detection4.2 collision detection
4.2 collision detectionSayed Ahmed
 

Similar a ACM ICPC 2015–2016 Northeastern European Regional Contest Problems Review (20)

SIAM - Minisymposium on Guaranteed numerical algorithms
SIAM - Minisymposium on Guaranteed numerical algorithmsSIAM - Minisymposium on Guaranteed numerical algorithms
SIAM - Minisymposium on Guaranteed numerical algorithms
 
Computer Network Homework Help
Computer Network Homework HelpComputer Network Homework Help
Computer Network Homework Help
 
M112rev
M112revM112rev
M112rev
 
cheb_conf_aksenov.pdf
cheb_conf_aksenov.pdfcheb_conf_aksenov.pdf
cheb_conf_aksenov.pdf
 
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory Based
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory BasedJEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory Based
JEE Main 2020 Question Paper With Solution 08 Jan 2020 Shift 1 Memory Based
 
Algorithms Exam Help
Algorithms Exam HelpAlgorithms Exam Help
Algorithms Exam Help
 
Rand final
Rand finalRand final
Rand final
 
Semet Gecco06
Semet Gecco06Semet Gecco06
Semet Gecco06
 
Mit15 082 jf10_lec01
Mit15 082 jf10_lec01Mit15 082 jf10_lec01
Mit15 082 jf10_lec01
 
Algorithm Assignment Help
Algorithm Assignment HelpAlgorithm Assignment Help
Algorithm Assignment Help
 
numerical.ppt
numerical.pptnumerical.ppt
numerical.ppt
 
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docxDivide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
Divide-and-Conquer & Dynamic ProgrammingDivide-and-Conqu.docx
 
Ch2 2011 s
Ch2 2011 sCh2 2011 s
Ch2 2011 s
 
Ece512 h1 20139_621386735458ece512_test2_solutions
Ece512 h1 20139_621386735458ece512_test2_solutionsEce512 h1 20139_621386735458ece512_test2_solutions
Ece512 h1 20139_621386735458ece512_test2_solutions
 
rgDefense
rgDefensergDefense
rgDefense
 
Answers withexplanations
Answers withexplanationsAnswers withexplanations
Answers withexplanations
 
3rd Semester Electronic and Communication Engineering (2013-December) Questio...
3rd Semester Electronic and Communication Engineering (2013-December) Questio...3rd Semester Electronic and Communication Engineering (2013-December) Questio...
3rd Semester Electronic and Communication Engineering (2013-December) Questio...
 
Design and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation AlgorithmsDesign and Implementation of Parallel and Randomized Approximation Algorithms
Design and Implementation of Parallel and Randomized Approximation Algorithms
 
4.2 collision detection
4.2 collision detection4.2 collision detection
4.2 collision detection
 
Alex1 group2
Alex1 group2Alex1 group2
Alex1 group2
 

Más de 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 Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Roman 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
 
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
 
Пишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхПишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхRoman Elizarov
 

Más de Roman Elizarov (15)

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
 
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
Теоретический минимум для понимания Java Memory Model (для JPoint 2014)
 
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
 
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
 
Пишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данныхПишем самый быстрый хеш для кэширования данных
Пишем самый быстрый хеш для кэширования данных
 

Último

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Último (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.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
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

ACM ICPC 2015–2016 Northeastern European Regional Contest Problems Review

  • 1. ACM ICPC 2015–2016 Northeastern European Regional Contest Problems Review Roman Elizarov December 6, 2015
  • 2. Problems summary Recap: 224 teams, 12 problems, 5 hours, 20-th NEERC — Jubilee This review assumes the knowledge of the problem statements (published separately on http://neerc.ifmo.ru/ web site) Summary table on the next slide lists problem name and stats author — author of the original idea acc — number of teams that had solved the problem (gray bar denotes a fraction of the teams that solved the problem) runs — number of total attempts succ — overall successful attempts rate (percent of accepted submissions to total, also shown as a bar)
  • 3. Problems summary (2) problem name author acc/runs succ Adjustment Office Vitaliy Aksenov 196 /522 37% Binary vs Decimal Mikhail Tikhomirov 12 /83 14% Cactus Jubilee Mikhail Tikhomirov 14 /28 50% Distance on Triangulation Gennady Korotkevich 9 /67 13% Easy Problemset Andrey Lopatin 208 /281 74% Froggy Ford Georgiy Korneev 101 /602 16% Generators Elena Andreeva 153 /533 28% Hypercube Oleg Khristenko 3 /15 20% Iceberg Orders Egor Kulikov 0 /2 0% Jump Maxim Buzdalov 52 /577 9% King’s Inspection Mikhail Dvorkin 24 /253 9% Landscape Improved Georgiy Korneev 56 /213 26%
  • 4. Problem A. Adjustment Office Total time 0h 1h 2h 3h 4h 5h 196 326 Java C++ Total Accepted 17 179 196 Rejected 53 273 326 Total 70 452 522 solution team att time size lang Fastest SPbAU 1 1 7 1,051 C++ Shortest NU 14 2 41 529 C++ Max atts. UrSU 2 10 130 1,650 Java
  • 5. Problem A. Adjustment Office (1) Recap: n × n grid, each cell (x, y) has value x + y Initial sum at row or column k is equal to nk + n(n+1) 2 Maintain two pieces of data for rows and columns: The set of all zeroed out rows Sr and columns Sc, initially both sets are empty Two sums sr,c = i∈{1...n}Sr,c i, initially both sums are n(n+1) 2 The result of row query “R r” is equal to: n −|Sc| r + sc if r /∈ Sr 0 otherwise If r /∈ Sr, then Sr ← Sr ∪ {r} and sr ← sr − r Similarly for column queries
  • 6. Problem B. Binary vs Decimal Total time 0h 1h 2h 3h 4h 5h 12 71 Java C++ Total Accepted 4 8 12 Rejected 4 67 71 Total 8 75 83 solution team att time size lang Fastest SPb SU 1 2 73 1,914 Java Shortest ITMO 1 1 112 1,193 Java Max atts. MAI 5 269 256,031 C++
  • 7. Problem B. Binary vs Decimal (1) It is easy to prove that 10k 2 has 2k 2 as a suffix, for example: decimal binary 110 12 1010 10102 10010 11001002 100010 11111010002 Let Ck be a set of all numbers less than 10k, whose decimal representation is equal to its k last binary digits Let Ck = Ak ∪ Bk, where all x ∈ Ak have k-th (counting from zero) digit of 0 and all x ∈ Bk have k-th digit of 1 Bk is a set of bindecimal numbers of length k — one we want k Ak Bk 0 {0} {} 1 {0} {1} 2 {0, 1} {10, 11} 3 {0, 1, 10, 11} {100, 101, 110, 111} 4 {0, 1, 100, 101} {1000, 1001, 1100, 1101}
  • 8. Problem B. Binary vs Decimal (2) Define a recursive rule to get Ck from Ck−1 Ak = x x ∈ Ck−1 and k-th bit of x is zero Bk = x + 10k x ∈ Ck−1 and k-th bit of x is zero Ck = Ak ∪ Bk Keep Ck as an ordered list, so when new Bk is computed as defined above, the bindecimal numbers in Bk are produced in ascending order; count them; stop when n-th bindecimal number is found Note, that the max answer for n = 10 000 is around 10161, so it will not fit into any standard data types; need long arithmetics to implement it
  • 9. Problem C. Cactus Jubilee Total time 0h 1h 2h 3h 4h 5h 14 14 Java C++ Total Accepted 0 14 14 Rejected 0 14 14 Total 0 28 28 solution team att time size lang Fastest Saratov SU 4 1 124 3,673 C++ Shortest Ural FU 1 2 151 2,735 C++ Max atts. MIPT 2 4 279 3,487 C++
  • 10. Problem C. Cactus Jubilee (1) Depth-first search (DFS) of the cactus to split the edges of the cactus into disjoint sets of bridge-trees Bi and cycles Ci Each back edge found during DFS signals a cycle Compute size of each Bi and a number of non-adjacent pairs of edges during the first DFS; do a second DFS to push it to all adjacent cycles 1 2 3 4 5 6 7 8 9 10 11 1213 14 15 C1 C2 C3 C4 B1
  • 11. Problem C. Cactus Jubilee (2) When an edge from a bridge-tree Bi is removed, cactus splits into two connected components any pair of vertices from these two components can be reconnected to get a cactus number of ways can be counted during initial DFS 1 2 3 4 5 6 7 8 9 10 11 1213 14 15
  • 12. Problem C. Cactus Jubilee (3) When an edge from a cycle Ci is removed, cactus is still connected; bridge-trees adjacent to cycle merge any pair of non-adjacent vertices from the same bridge-tree can be connected to get a cactus Scan all cycles to figure out the the number of ways to add an edge for each cycle broken; multiple by the cycle size 1 2 3 4 5 6 7 8 9 10 11 1213 14 15
  • 13. Problem D. Distance on Triangulation Total time 0h 1h 2h 3h 4h 5h 9 58 Java C++ Total Accepted 0 9 9 Rejected 2 56 58 Total 2 65 67 solution team att time size lang Fastest NNSU 1 145 4,602 C++ Shortest SPbAU 1 1 235 3,579 C++ Max atts. SPb SU 3 6 266 7,846 C++
  • 14. Problem D. Distance on Triangulation (1) Divide and conquer; prove that each triangulated polygon has a diagonal that cuts at least n/3 vertices Randomly picking a diagonal does not work — will time limit Recursively split polygons this way for a total depth of O(log n); get O(n) subpolygons of total size O(n log n) Terminal subpolygons for this problem are the ones that do not have have any diagonals to split them further — triangles 1 2 3 45 6
  • 15. Problem D. Distance on Triangulation (2) For each subpolygon precompute the shortest distances from two ends of the diagonals of that was used to cut out this subpolygon from the large one O(n log n) total memory to store the distances Can be done in O(n log n) by doing breadth-first search in each subpolygon or in O(n log2 n) by doing recursive queries (see below for query implementation) Each query can be answered in O(log n) recursively Terminal subpolygon (triangle) — trivial x and y in query are both on one side of splitting diagonal — recursive query into the corresponding subpolygon x and y in query are on different sides — use precomputed distances to diagonal ends (diagonals do not intersect, so x − y path goes through one of the ends)
  • 16. Problem E. Easy Problemset Total time 0h 1h 2h 3h 4h 5h 208 73 Java C++ Total Accepted 17 191 208 Rejected 9 64 73 Total 26 255 281 solution team att time size lang Fastest Ural FU 1 1 8 1,011 C++ Shortest NU 14 1 22 426 C++ Max atts. Kyrgyz-Turkish U 1 5 188 781 C++
  • 17. Problem E. Easy Problemset (1) The easiest problem Just implement what the problem statement says Pay attention to judges without remaining problems — don’t forget to propose a hard problem Sample inputs and outputs were designed to expose all the tricky cases to make debugging easy
  • 18. Problem F. Froggy Ford Total time 0h 1h 2h 3h 4h 5h 101 501 Java C++ Total Accepted 5 96 101 Rejected 12 489 501 Total 17 585 602 solution team att time size lang Fastest NNSU 1 41 2,281 C++ Shortest ITMO 4 1 85 1,600 C++ Max atts. Saratov SU 3 19 217 3,797 C++
  • 19. Problem F. Froggy Ford (1) Consider a graph with vertices 1, . . . n corresponding to stones, 0 for the left shore, n + 1 for the right one; obvious way to compute distances between vertices The problem of finding the optimal route from 0 to n + 1 as defined in problem is called minimax path problem 1 2 3 4 5 6 7 0 8
  • 20. Problem F. Froggy Ford (2) Minimax path form 0 to all other vertices can be found by Djikstra algorithm with a corresponding minimax update rule; O(n2); no need to even have a heap in Djikstra Second invocation of the same algo to find minimax path from n + 1 to all others A new optimal stone can be only at the center between a pair of vertices (stone – stone, stone – shore, shore – shore) Check all pairs of vertices; O(n2 ) Use precomputed distances to 0 and to n + 1 to find distance when new stone is placed; pick the optimal case Make sure to correctly implement distances between shores (vertices 0 and n + 1); this case is not covered in sample input
  • 21. Problem G. Generators Total time 0h 1h 2h 3h 4h 5h 153 380 Java C++ Total Accepted 9 144 153 Rejected 53 327 380 Total 62 471 533 solution team att time size lang Fastest MSU 3 1 29 3,169 C++ Shortest Ural FU 4 2 86 1,136 C++ Max atts. Far Eastern FU 19 262 1,699 C++
  • 22. Problem G. Generators (1) Recap: x (j) i+1 = a(j)x (j) i + b(j) mod c(j) Generate c(j) numbers for each LCG — produce all numbers this LCG can possibly generate; for each LCG find: the maximum x (j) tj ; pay attention to x (j) 0 (don’t skip it) the second maximum x (j) uj , such that x (j) tj − x (j) uj mod k = 0 Pay attention to cases when there is no second maximum, e.g. all generated numbers are the same or all differences between them are multiples of k When n j=1 x (j) tj mod k = 0 — that’s the answer Otherwise, find j such that x (j) tj − x (j) uj is maximized (if at least one second maximum uj exists) and replace tj with uj Otherwise, there is no answer
  • 23. Problem H. Hypercube Total time 0h 1h 2h 3h 4h 5h 3 12 Java C++ Total Accepted 0 3 3 Rejected 0 12 12 Total 0 15 15 solution team att time size lang Fastest SPb SU 1 1 175 2,241 C++ Shortest SPb SU 1 1 175 2,241 C++ Max atts. Ural FU 1 3 289 5,628 C++
  • 24. Problem H. Hypercube (1) Disassemble tesseract into 8 cubic cells Start with an arbitrary cube of an octocube, assume it corresponds to an arbitrary cell of tesseract Visit all cubes of a given octocube via DFS Each time a cube is visited, see what cell it shall correspond to and if that cell was not used yet There are two conceptual ways to uniquely identify tesseract’s cells and to traverse them 3D geometry — represent each cell via numbering of its 8 vertices; no 4D vector manipulations required 4D geomerty — represent each cell via a 4D vector normal; leads to simpler code
  • 25. Problem H. Hypercube (2) Disassembled tesseract with numbered vertices and normals (-1,0,0,0) (1,0,0,0) (0,-1,0,0) (0,1,0,0) (0,0,-1,0) (0,0,1,0) (0,0,0,-1) (0,0,0,1) 0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 0 8 4 12 1 9 5 13 2 10 6 14 3 11 7 15 0 8 2 10 1 9 3 11 4 12 6 14 5 13 7 15 0 4 2 6 1 5 3 7 8 12 10 14 9 13 11 15 x y t z
  • 26. Problem H. Hypercube (3) Solution using 3D geometry All vertices of a tesseract are numbered from 0 to 15 Cell in a tesseract are represented by cubes of 8 vertex indices Moving in one of 6 directions in an given octocube, find 4 vertices in that direction on a corresponding face of the current cube Among remaining cells find the one that can be rotated/flipped (in 3D) to get a match of vertices face-to-face — this is the next cell and its 3D rot’n/flip 0 4 2 6 1 5 3 7 1 5 3 7 9 13 11 15
  • 27. Problem H. Hypercube (4) Solution using 4D geometry Keep track of a 4 × 4D vectors: 3 vectors define a basis for current cell’s hyperplane, 4th vector defines a normal A normal also uniquely identifies a cell of a tesseract Moving in one of 6 directions in an given octocube, the corresponding basis vector of the current hyperplane (multiplied by ±1 depending on direction in the axis) becomes the normal of the next cell; the former normal replaces basis vector in that direction (multiplied by 1) — proper 4D rot’n x y z norm (0,0,0,-1) x (0,0,0,1) y z norm (1,0,0,0)
  • 28. Problem I. Iceberg Orders Total time 0h 1h 2h 3h 4h 5h 2 Java C++ Total Accepted 0 0 0 Rejected 0 2 2 Total 0 2 2
  • 29. Problem I. Iceberg Orders (1) The structure of the code is hinted in the statement: keep buy and sell orders in the book separately in a sorted tree maps keyed by the price at each price keep a list of orders ordered by priority this way finding a set of orders to match with is efficient — O(k), where k is the number of orders to match with The solution is then mostly boils down to implementing what the problem statement says, with one tricky case When big order (volume Va is big) comes in, it produces a lot of trades with other orders that have small tip value TVb; namely O(Va) trades — too many to simulate directly Recap: Va is up to 109; while the total number of different matched order pairs is guaranteed not to exceed 105
  • 30. Problem I. Iceberg Orders (2) The tricky case is addressed by figuring out how many times m an incoming order fully matches with all orders at a current price level m is found using binary search in O(p log Va) operations, where p is the number of orders at a given price level Then, all the m matches can be simulated at one pass in O(p); simulating remaining pass directly Care shall taken be in two additional cases when p k make sure that O(k) operations are performed — must do one direct order-by-order match at a given price level first when incoming order volume Va is so big that the whole price level with k orders is consumed, must do it in O(k); can afford additional log in binary search only at the last matched price level
  • 31. Problem J. Jump Total time 0h 1h 2h 3h 4h 5h 52 525 Java C++ Total Accepted 1 51 52 Rejected 43 482 525 Total 44 533 577 solution team att time size lang Fastest Ural FU 1 1 33 1,401 C++ Shortest Ural FU 4 5 286 905 C++ Max atts. Perm SU 1 7 251 1,323 C++
  • 32. Problem J. Jump (1) Recap: must solve in n + 500 queries Solve the problem in two phases: Phase I with up to 499 queries and Phase II with up to n + 1 queries Phase I: find QI such that Jump(QI) = n/2 do random queries in this phase worst case when n = 1000, probability of guessing n/2 bits in a single random query is (1000 500 ) 21000 = 0.0252 . . . probability of not finding QI in 499 queries is 2.9 × 10−6 Just quit if Jump(QI) = n is found Phase II: find solution QII such that Jump(QII) = n for i = 2 . . . n do queries with Qi ={QI bits 0 and i flipped} Jump(Qi ) = n/2 if bits 0 and i has the same “correctness” assume 0 is correct bit in QI; make QII={QI all bits j flipped} where Jump(Qj ) = n/2; try query QII; quit if got n assume 0 is not correct; make QII={QI all bits j flipped} where j = 0 or Jump(Qj ) = n/2; must get Jump(QII) = n
  • 33. Problem K. King’s Inspection Total time 0h 1h 2h 3h 4h 5h 24 229 Java C++ Total Accepted 0 24 24 Rejected 6 223 229 Total 6 247 253 solution team att time size lang Fastest MIPT 5 2 102 2,920 C++ Shortest ITMO 1 3 212 2,164 C++ Max atts. NEFU 1 9 279 2,865 C++
  • 34. Problem K. King’s Inspection (1) Count in-degree din i and out-degree dout i for each city i; there is no route if either is zero for any city (important check!) Identify special cites i: capital (i = 1) and cities with din i > 1 or dout i > 1; there are at most 41 special cities Other cities are ordinary captial (special) 1 2 ordinary ordinary 3 4 special
  • 35. Problem K. King’s Inspection (2) Merge all paths between special cities though ordinary cities. Ordinary cities: non-capital and din i = 1 and dout i = 1 For each special city create a list of outgoing paths to other special cities there is no route if more than one outgoing path from a special city requires going through ordinary cities if there is one outgoing path through ordinary cities, make it the only path in the outgoing list captial (special) 1 2 3 4 special
  • 36. Problem K. King’s Inspection (3) The picture shows properly reduced graph; but the list of cities on the reduced paths is still kept to print the answer Do exhaustive search (backtracking) for a path — at most 220 operations There are at most 20 special cities with some choice (more that 1 outgoing path in list) captial (special) 1 2 3 4 special
  • 37. Problem L. Landscape Improved Total time 0h 1h 2h 3h 4h 5h 56 157 Java C++ Total Accepted 2 54 56 Rejected 8 149 157 Total 10 203 213 solution team att time size lang Fastest Saratov SU 4 1 53 2,969 C++ Shortest Kazakh-British TU 2 5 289 1,465 C++ Max atts. MIPT 3 9 298 2,880 C++
  • 38. Problem L. Landscape Improved (1) Do binary search for the answer; try O(log n) guesses at the answer in the process For each guess m of the answer count the number of squares of stones required to build a mountain of height m, if it is possible; compare the result with n Let ri be the number of squares of stones required to support the mountain of height m with a peak at i at the right i = 2 m = 7 r2 = 9
  • 39. Problem L. Landscape Improved (2) Let li — the number to support at the left Total number of squares ti = li + ri + m − hi The number of required squares is min ti for all i ri is computed with a single pass for i from 1 to w in O(w) li with a single pass for i from w to 1 overall time to find a solution is O(w log n) i = 2 m = 7 l2 = inf cannot support at the left
  • 40. Credits Special thanks to all jury members and assistants (in alphabetic order): Alexander Kaluzhin, Andrey Lopatin, Andrey Stankevich, Artem Vasilyev, Borys Minaiev, Demid Kucherenko, Dmitry Shtukenberg, Egor Kulikov, Elena Andreeva, Gennady Korotkevich, Georgiy Korneev, Gleb Evstropov, Grigoriy Shovkoplyas, Maxim Buzdalov, Mikhail Dvorkin, Mikhail Pyaderkin, Mikhail Tikhomirov, Nikita Kravtsov, Niyaz Nigmatullin, Oleg Hristenko, Pavel Krotkov, Pavel Kunyavsky, Pavel Mavrin, Petr Mitrichev, Viktor Omelyanenko, Vitaly Aksenov