![Page 1: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/1.jpg)
Problem Analysis Session
SWERC judges
December 2, 2018
SWERC judges Problem Analysis Session December 2, 2018 1 / 29
![Page 2: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/2.jpg)
Statistics
Number of submissions: about 2500Number of clarification requests: 28 (20 answered “No comment.”)
Languages:
1533 C++
34 C
232 Java
330 Python 2
233 Python 3
SWERC judges Problem Analysis Session December 2, 2018 2 / 29
![Page 3: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/3.jpg)
A – City of Lights
Solved by 83 teams before freeze.First solved after 6 min by TeamRockETH.
SWERC judges Problem Analysis Session December 2, 2018 3 / 29
![Page 4: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/4.jpg)
A – City of Lights
This was the easiest problem of the contest.
Problem
Toggle regularly spaced lights at every step, and print the maximumnumber of turned-off lights.
Straightforward solution
Keep an array with the light status (or a bit set).
Keep the number of currently turned-off lights in a variable.
SWERC judges Problem Analysis Session December 2, 2018 4 / 29
![Page 5: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/5.jpg)
K – Dishonest Driver
Solved by 18 teams before freeze.First solved after 17 min by TeamRaclETH.
SWERC judges Problem Analysis Session December 2, 2018 5 / 29
![Page 6: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/6.jpg)
K – Dishonest Driver
Problem
Given a string, compute the length of its shortest compressed form.How to build a compressed form:
one character c (size: |c| = 1),
concatenation w1w2 (size: |w1w2| = |w1|+ |w2|),
repetition (w)n (size: |(w)n| = |w |).
SWERC judges Problem Analysis Session December 2, 2018 6 / 29
![Page 7: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/7.jpg)
K – Dishonest Driver
Solution in time O(N3)
Dynamic programming on:
F (i , j) = size of compressed form of substring uij = ui . . . uj−1
If j = i + 1, then F (i , j) = 1. Otherwise:
Try splitting uij = uikukj for any position k ∈ [i + 1, j − 1];
Try factorizing uij into uij = unik :
What are the factorizations of uij?Trick: search second occurence of uij in uijuijO(N) with KMP (e.g., use C++ stdlib find function)
Note: we also have a O(N2 logN) algorithm
SWERC judges Problem Analysis Session December 2, 2018 7 / 29
![Page 8: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/8.jpg)
E – Rounding
Solved by 39 teams before freeze.First solved after 23 min by SNS 1.
SWERC judges Problem Analysis Session December 2, 2018 8 / 29
![Page 9: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/9.jpg)
E – Rounding
First bounds
Each monument m with rounded value roundm had an original valueoriginm such that:
originm > minm, with minm = max{0, roundm − 0.50};originm 6 maxm, with maxm = min{100, roundm + 0.49}.
Possible or not?
Possible if and only if∑m
minm 6 100 6∑m
maxm.
SWERC judges Problem Analysis Session December 2, 2018 9 / 29
![Page 10: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/10.jpg)
E – Rounding
Solution
Compute minSum =∑
mminm and maxSum =∑
mmaxm
Return IMPOSSIBLE if minSum > 100 or maxSum < 100
Real minimal value for monument m:realMinm = max{minm,maxm − (maxSum− 100)}Real maximal value for monument m:realMaxm = min{maxm,minm + (100−minSum)}
Main causes for wrong answers
Allowing original values < 0 or > 100
Using floating point numbers
Result formatting issues
SWERC judges Problem Analysis Session December 2, 2018 10 / 29
![Page 11: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/11.jpg)
B – Blurred pictures
Solved by 28 teams before freeze.First solved after 29 min by UPC-1.
SWERC judges Problem Analysis Session December 2, 2018 11 / 29
![Page 12: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/12.jpg)
B – Blurred pictures
Dynamic programming on the grid wouldtake time O(N ×N) −→ time limit exceeded
Note that perimeter is in O(N) and use it tocompute only the mandatory extreme valuesin time O(N).
Even simpler:
You only need to keep track of the sizeof the largest square.
Start from the first line and grow themaximum square from there, increasingits size at each new line when possible,else changing the starting line.
SWERC judges Problem Analysis Session December 2, 2018 12 / 29
![Page 13: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/13.jpg)
B – Blurred pictures
Dynamic programming on the grid wouldtake time O(N ×N) −→ time limit exceeded
Note that perimeter is in O(N) and use it tocompute only the mandatory extreme valuesin time O(N).
Even simpler:
You only need to keep track of the sizeof the largest square.
Start from the first line and grow themaximum square from there, increasingits size at each new line when possible,else changing the starting line.
SWERC judges Problem Analysis Session December 2, 2018 12 / 29
![Page 14: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/14.jpg)
B – Blurred pictures
Dynamic programming on the grid wouldtake time O(N ×N) −→ time limit exceeded
Note that perimeter is in O(N) and use it tocompute only the mandatory extreme valuesin time O(N).
Even simpler:
You only need to keep track of the sizeof the largest square.
Start from the first line and grow themaximum square from there, increasingits size at each new line when possible,else changing the starting line.
SWERC judges Problem Analysis Session December 2, 2018 12 / 29
![Page 15: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/15.jpg)
D – Monument Tour
Solved by 38 teams before freeze.First solved after 37 min by Blaise1.
SWERC judges Problem Analysis Session December 2, 2018 13 / 29
![Page 16: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/16.jpg)
D – Monument Tour
Coordinates
0, 2, 2, 2, 3, 3, 3, 6
Solution
the main road will always passthrough at least one monument
the best placement is the medianof the y coordinates of the extremepoints of “monument segments”
Monument Segment
keep only the extremes of ycoordinates corresponding to thesame x
count single points as a segment(i.e., count y coordinate twice)
SWERC judges Problem Analysis Session December 2, 2018 14 / 29
![Page 17: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/17.jpg)
F – Paris by Night
Solved by 13 teams before freeze.First solved after 83 min by TeamRaclETH.
SWERC judges Problem Analysis Session December 2, 2018 15 / 29
![Page 18: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/18.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197211
5
5
10
10
2
2
1212
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 19: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/19.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197211
5
5
10
10
2
2
1212
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 20: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/20.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
151972
11
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 21: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/21.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197
211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 22: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/22.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
1519
7211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 23: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/23.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15
197211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 24: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/24.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 25: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/25.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 26: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/26.jpg)
F – Paris by Night
Naive approach in time O(N3)
For all pairs of limiting monuments M 6=M′,compute the grade difference ∆M,M′ from scratch.
|∆|=7
|∆|=2
32
32
10
8
7
12 14
5
Better approach in time O(N2 log(N))
For all limiting monuments M:
order monuments M′ 6=M clockwise,based on the direction of (MM′);
compute differences ∆M,M′ incrementally.
-16
-4
15197211
5
5
10
10
2
2
12
12
3
3
14
14
7
7
8
SWERC judges Problem Analysis Session December 2, 2018 16 / 29
![Page 27: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/27.jpg)
I – Mason’s Mark
Solved by 8 teams before freeze.First solved after 100 min by ENS Ulm 1.
SWERC judges Problem Analysis Session December 2, 2018 17 / 29
![Page 28: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/28.jpg)
I – Mason’s Mark
Many solutions are possible. For example:
Find connected components in a grid
Black dots form connected components, one of them contains the frame,others are single noise dots, and the remaining correspond to marks.
One possibility
Let M be manson’s mark. Determining its bounding box. Now eitherinspect two particular points, or comparing the size of M with a threshold,in order to determine the type of M.
SWERC judges Problem Analysis Session December 2, 2018 18 / 29
![Page 29: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/29.jpg)
H – Travel Guide
Solved by 4 teams before freeze.First solved after 118 min by TeamRaclETH.
SWERC judges Problem Analysis Session December 2, 2018 19 / 29
![Page 30: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/30.jpg)
H – Travel Guide
Moving from a graph problem towards a vector problem
Three passes of Dijkstra algorithm to compute the distance from each POIto each node. O(|E | × log(|E |))
We sort the vectors bylexicographical order.
x1 y1 z1x2 y2 z2x3 y3 z3. . .xn yn zn
Key observation
A vector vi is minimal iff it is minimal amongthe vectors v1, . . . , vi without considering the xcoordinate.
SWERC judges Problem Analysis Session December 2, 2018 20 / 29
![Page 31: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/31.jpg)
H – Travel Guide
Idea: Maintain the 2D minimal vectors
Maintain a list of minimal vectors sorted by increasing y with a tree.Note that it is sorted by decreasing z!
y
zChecking that (y , z) is minimal
Is z < z ′ for all (y ′, z ′) withy ′ < y?
Inserting (y , z) as a minimal
Remove all z < z ′ and y ′ < y?
Note that you need to deal withduplicates.
SWERC judges Problem Analysis Session December 2, 2018 21 / 29
![Page 32: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/32.jpg)
J – Mona Lisa
Solved by 1 team before freeze.First solved after 154 min by ENS Ulm 1.
SWERC judges Problem Analysis Session December 2, 2018 22 / 29
![Page 33: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/33.jpg)
J – Mona Lisa
Problem
Given 4 streams X1,X2,X3,X4 of pseudo-random n-bit integers, findx1 ∈ X1, . . . , x4 ∈ X4 such that x1 ⊕ x2 ⊕ x3 ⊕ x4 = 0.
Naive solution in O(2n/2) (exceeds time limit)
Store O(2n/2) values from X1 in a hashmap.
Pick x3 ∈ X3 and x4 ∈ X4 arbitrarily.
Iterate over x2,i ∈ X2, look for x2,i ⊕ x3 ⊕ x4 in the hashmap.
We expect to find a match after O(2n/2) steps by Birthday Paradox.
SWERC judges Problem Analysis Session December 2, 2018 23 / 29
![Page 34: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/34.jpg)
J – Mona Lisa
Solution in O(2n/3) (space and time)
Build a list of x1 ⊕ x2 when x1 and x2 match on their n/3 leastsignificant bits. When using O(2n/3) values from X1 and X2, the listhas O(2n/3) elements by Birthday Paradox.
Do the same on X3,X4.
The two lists generated have O(2n/3) elements of only 2n/3 bits. ByBirthday paradox, we expect O(1) matches.
SWERC judges Problem Analysis Session December 2, 2018 24 / 29
![Page 35: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/35.jpg)
J – Mona Lisa
O(2n/3) collisions
O(1) collisions
X1 X2 X3 X4
... 0 · · · 0 ... 0 · · · 0
0000000 · · · 0000000
n/3 n/3
SWERC judges Problem Analysis Session December 2, 2018 25 / 29
![Page 36: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/36.jpg)
G – Strings
Solved by 1 team before freeze.First solved after 235 min by ENS Ulm 1.
SWERC judges Problem Analysis Session December 2, 2018 26 / 29
![Page 37: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/37.jpg)
G – Strings
Source
Ropes: an Alternative to StringsBoehm, Atkinson, Plass, 1995
Main ideas
do not concatenate strings,build binary trees instead
ropes are immutable,thus sharing is possible
Implementation
rope length in O(1)
substring of a leaf in O(1),else recursively in O(N)
Example
App
App
" within " App
"a " "string"
Overall complexity
O(N2)
SWERC judges Problem Analysis Session December 2, 2018 27 / 29
![Page 38: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/38.jpg)
C – Crosswords
Not solved before freeze.
SWERC judges Problem Analysis Session December 2, 2018 28 / 29
![Page 39: Problem Analysis Session - SWERC · 2018-12-02 · SWERC judges Problem Analysis Session December 2, 2018 4/29. K { Dishonest Driver Solved by 18 teams before freeze. First solved](https://reader030.vdocuments.mx/reader030/viewer/2022040619/5f2e33ce75737b2c8a415fa2/html5/thumbnails/39.jpg)
C – Crosswords
Source
Knuth, The Art of Computer Programmingforthcoming volume 4B, pre-fascicle 5b Introduction to BacktrackingWord Rectangles (page 8)
Backtracking Algorithm
fill the grid, in any order
+1 when completely filled
s w e r co a
Data Structure
build two tries, for horizontal andvertical words
maintain pointers into these tries,for the columns and the row
speed up the lookup at theintersection with sparse, sortedbranches in your tries (see ex. 28)
SWERC judges Problem Analysis Session December 2, 2018 29 / 29