Infoleague Autumn 2021 Round 2 Division 1 Editorial

Revision en3, by valeriu, 2021-11-20 22:36:22

103423A - Bordered Subarrays

Solution
Subtask 2
Subtask 3
Subtask 4
Subtask 5

103423B - Vacuum Cleaner

It is very uncomfortable for us to keep track of Gigi's players. More specifically, it's awkward to note the fact that each second we must update all the blocked positions due to their movement. So, we make the following claim: A pass is unsuccesful if the segment [ (x_1,y), (x_2, y + (x_2-x_1)) ] intersects any player of Gigi's.

the initial arrangement

the initial arrangement

the arrangement, as defined by the ammendement we made earlier

the arrangement, as defined by the ammendement we made earlier

the arrangement, as defined by the statement

the arrangement, as defined by the statement

We can prove this by induction. First, when we refer to (a,b)=1 at some time, it means that this point will be blocked at that time.

Base case: $$$(a+1,b), T=1 <=> (a+1,b+1), T=0$$$ (i.e. they are equivalent points at different times)

This derives from the statement, since if $$$(a+1,b+1), T=0$$$, then $$$(a+1-1,b+1), T=1$$$

Inductive step:

$$$((a+x,b), T=x <=> (a+x,b+x), T=0) ==> ((a+x+1,b), T=x <=> (a+x+1,b+x+1), T=0)$$$

applying the base case on $$$(a+x+1,b+x), T=0$$$ we get

$$$(a+x+1,b+x), T=1 <=> (a+x+1,b+x+1), T=0$$$

then again, by default, we have

$$$(a,b)=val, T=x <=> (c,d)=val, T=y <===> (a+1,b), T=x+1 <=> (c+1,d), T=y.$$$

So

$$$(a+x+1,b+x), T=1 <=> (a+x+1,b+x+1), T=0$$$

And

$$$ (a+x,b), T=x <=> (a+x,b+x), T=0 $$$

, so

$$$ (a+x+1,b+x+1) T=0 <=> (a+x+1,b+x),T=1 <=> (a+x+1,b+1),T=x+1 $$$

QED

Now, let's assume we have to solve the following problem:

Given some vertical segments, determine for each query consisting of a horisontal segment if this intersects any of the earlier given segments.

This is a classical exaample of a problem that can be solved using the technique of line-sweeping. The solution we know, at least, is the following: sort both the vertical segments and the horizontal ones by their greatest X-coordinate. Then: A vertical segment is an update on all the Y-coordinates it covers. A horizontal segment is a point-query that asks if the latest vertical segment that covers this Y-coordinate happened after the left-X-limit of the segment. This can be solved using a Segment Tree with lazy propagation

The problem is that momentarily we have queries on lines parallel to ( (0,0), (1,1) ), and segments for updates parallel to Oy. With more consideration, we can say that we are currently working in the space defined by

$$$ \begin{pmatrix} 1 & 0 \\ 1 & 1 \end{pmatrix} $$$

So, we have to transform it to

$$$ \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix} $$$

This can be obviously done by multiplying with the inverse of the first matrix (by the definition of matrixes) and then multiplying it with the latter (which is the identity matrix, so it won't have any effect). The inverse we are talking about is of course:

$$$ \begin{pmatrix} 1 & 0 \\ -1 & 1 \end{pmatrix} $$$

The effect on this matrix on ever \sout{point} vector in the plane is basically just subtracting the x-coordinate value from the y-coordinate value. So we use this to recalculate the input to the "normal" version. Then we can use the sweep-line algorithm we described earlier to solve the problem.

Time complexity: $$$O((N+M)*(log(N+M)+log(COORDMAX)))$$$

Space complexity: $$$O(N+M+COORDMAX)$$$

Author's Note

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en20 English valeriu 2021-11-23 14:50:22 10
en19 English valeriu 2021-11-23 14:49:39 5
en18 English valeriu 2021-11-23 11:38:27 4
en17 English valeriu 2021-11-20 23:35:37 7
en16 English valeriu 2021-11-20 23:14:40 2
en15 English valeriu 2021-11-20 23:07:09 85
en14 English valeriu 2021-11-20 23:05:37 186
en13 English valeriu 2021-11-20 23:03:23 63
en12 English valeriu 2021-11-20 23:00:41 13
en11 English valeriu 2021-11-20 22:58:22 6
en10 English valeriu 2021-11-20 22:55:31 0 (published)
en9 English valeriu 2021-11-20 22:55:16 53
en8 English valeriu 2021-11-20 22:54:22 95
en7 English valeriu 2021-11-20 22:49:25 118
en6 English valeriu 2021-11-20 22:46:05 15
en5 English valeriu 2021-11-20 22:44:21 2272
en4 English valeriu 2021-11-20 22:42:25 300
en3 English valeriu 2021-11-20 22:36:22 2632
en2 English valeriu 2021-11-20 22:19:57 8
en1 English valeriu 2021-11-20 22:14:27 4262 Initial revision (saved to drafts)