Problem Analysis Session SWERC judges December 2, 2018 SWERC judges Problem Analysis Session December 2, 2018 1 / 29
Statistics Number of submissions: about 2500 Number 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
A – City of Lights Solved by 83 teams before freeze. First solved after 6 min by Team RockETH . SWERC judges Problem Analysis Session December 2, 2018 3 / 29
A – City of Lights This was the easiest problem of the contest. Problem Toggle regularly spaced lights at every step, and print the maximum number 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
K – Dishonest Driver Solved by 18 teams before freeze. First solved after 17 min by Team RaclETH . SWERC judges Problem Analysis Session December 2, 2018 5 / 29
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 w 1 w 2 (size: | w 1 w 2 | = | w 1 | + | w 2 | ), repetition ( w ) n (size: | ( w ) n | = | w | ). SWERC judges Problem Analysis Session December 2, 2018 6 / 29
K – Dishonest Driver Solution in time O ( N 3 ) Dynamic programming on: F ( i , j ) = size of compressed form of substring u ij = u i . . . u j − 1 If j = i + 1, then F ( i , j ) = 1. Otherwise: Try splitting u ij = u ik u kj for any position k ∈ [ i + 1 , j − 1]; Try factorizing u ij into u ij = u n ik : What are the factorizations of u ij ? Trick: search second occurence of u ij in u ij u ij O ( N ) with KMP (e.g., use C++ stdlib find function) Note: we also have a O ( N 2 log N ) algorithm SWERC judges Problem Analysis Session December 2, 2018 7 / 29
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
E – Rounding First bounds Each monument m with rounded value round m had an original value origin m such that: origin m � min m , with min m = max { 0 , round m − 0 . 50 } ; origin m � max m , with max m = min { 100 , round m + 0 . 49 } . Possible or not? Possible if and only if � � min m � 100 � max m . m m SWERC judges Problem Analysis Session December 2, 2018 9 / 29
E – Rounding Solution Compute minSum = � m min m and maxSum = � m max m Return IMPOSSIBLE if minSum > 100 or maxSum < 100 Real minimal value for monument m : realMin m = max { min m , max m − ( maxSum − 100) } Real maximal value for monument m : realMax m = min { max m , min m + (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
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
B – Blurred pictures Dynamic programming on the grid would take time O ( N × N ) − → time limit exceeded SWERC judges Problem Analysis Session December 2, 2018 12 / 29
B – Blurred pictures Dynamic programming on the grid would take time O ( N × N ) − → time limit exceeded Note that perimeter is in O ( N ) and use it to compute only the mandatory extreme values in time O ( N ). SWERC judges Problem Analysis Session December 2, 2018 12 / 29
B – Blurred pictures Dynamic programming on the grid would take time O ( N × N ) − → time limit exceeded Note that perimeter is in O ( N ) and use it to compute only the mandatory extreme values in time O ( N ). Even simpler: You only need to keep track of the size of the largest square. Start from the first line and grow the maximum square from there, increasing its size at each new line when possible, else changing the starting line. SWERC judges Problem Analysis Session December 2, 2018 12 / 29
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
D – Monument Tour Solution the main road will always pass through at least one monument the best placement is the median of the y coordinates of the extreme points of “monument segments” Monument Segment keep only the extremes of y coordinates corresponding to the same x count single points as a segment Coordinates (i.e., count y coordinate twice) 0, 2, 2, 2, 3, 3, 3, 6 SWERC judges Problem Analysis Session December 2, 2018 14 / 29
F – Paris by Night Solved by 13 teams before freeze. First solved after 83 min by Team RaclETH . SWERC judges Problem Analysis Session December 2, 2018 15 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =7 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 7 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 7 19 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 7 19 15 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 7 19 15 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 -4 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
F – Paris by Night 12 14 Naive approach in time O ( N 3 ) 8 For all pairs of limiting monuments M � = M ′ , 7 5 compute the grade difference ∆ M , M ′ from scratch. 2 3 10 | ∆ | =2 11 2 7 19 15 Better approach in time O ( N 2 log( N )) 12 14 For all limiting monuments M : 8 order monuments M ′ � = M clockwise, 7 5 -4 based on the direction of ( M M ′ ); 2 3 compute differences ∆ M , M ′ incrementally. 10 -16 SWERC judges Problem Analysis Session December 2, 2018 16 / 29
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
Recommend
More recommend