Блог пользователя lior5654

Автор lior5654, история, 5 лет назад, По-английски

Opening this thread to discuss Romanian Masters of Informatics (RMI) 2020 Problems & Results.

Hope everybody had a great competition!

http://rmi.lbi.ro/rmi_2020/

  • Проголосовать: нравится
  • +60
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +23 Проголосовать: не нравится

My results:

brperm — 83

floppy — 27

peru — 49

total (d1) — 160 (49th/198th)

zerosum — 61

nicelines — 11

arboras — 24

total (d2) — 96 (58th/198th)

total — 256 (??th/198th)

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится

My results:

brperm — 0
floppy — 100
peru — 0
total (d1) — 100

zerosum — 22
nicelines — 88.76
arboras — 24
total (d2) — 134.76

total — 234.76

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

My results are:

brperm 83, floppy 100, peru 0 -- 183 day1

zerosum 100, nicelines 0, arboras 24 -- 124 day2

307 total

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +13 Проголосовать: не нравится

    floppy 100 with a cartesian tree? I wish I knew what that is before the contest. on the go I invented a similar concept but wasn't full and good enough :/

    • »
      »
      »
      5 лет назад, скрыть # ^ |
      Rev. 2  
      Проголосовать: нравится +13 Проголосовать: не нравится

      I generated the max stack (1 = insertion, 0 = removal), then a "valid" permutation with a topological sort on the graph generated by the max stack.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +13 Проголосовать: не нравится

      To save the data in 2n bits, I found the highest value and used it as the root of a tree, then I divided the array recursively into left and right subtree, always choosing the highest value of the interval. Then, for each node of the tree in bfs order, I would save two bits, one is 1 if the node has a left child, the other is 1 if the current node has a right child. I would then reconstruct the tree, knowing that each node has a higher value than its children and its in-order traversal gives the original order of the array. For range max queries, I used a sparse table. I can send you a picture of the code if you want.

»
5 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится +43 Проголосовать: не нравится

My results:

bperm — 83; floppy — 28; peru — 18; total(d1) — 129

zerosum — 22; nicelines — 11; arboras — 24; total(d2) — 57

total — 186 (bronze)

Just to clarify — I am 14 years old (7th grade)

»
5 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится +36 Проголосовать: не нравится

So during the contest I came up with this solution for Arboras. However, I couldn't code it in time, so I don't know whether it's correct of not, so if someone could comment who knows the solution, would be appreciated.

First, it's not hard to see that all the values that change in a query lie on a path from the changed edge upwards. So let's apply heavy-light decomposition on the tree. For each chain, we keep a set of positions, where the longest path to a leaf starting from this vertex doesn't go through the heavy edge. Let's call this positions breaking-points.

When updating a vertex, go upwards from the changed edge. Call a vertex interesting if it is either the vertex where we change the chain when going upwards, or if it's a breaking-point. We can calculate the value-change on this points seperately. The value-change of the points between these interesting vertices can be updated easily, since the value-change of all of them is the same.

There are $$$\mathcal O(log \, n)$$$ interesting vertices of the first type on the path upwards. But we may encounter many vertices of the second type. Now comes the insight: Each time we encounter a point of interest of the second type, we either remove it from the set, or there isn't any value to change above it (since there is another longer path we could take). In the beginning, there can be at most $$$\mathcal O(n)$$$ breaking points, and in each update, we only add at most $$$\mathcal O(log\,n)$$$ breaking points, because we only change the chain (of the heavy-light decomposition) at most $$$\mathcal O(log \, n)$$$ times, and we can only add a breaking-point in an update when switching the chain. So, amortized, we check at most $$$\mathcal O(n \, log \, n)$$$ interesting points. With a segtree, the values can be maintained in $$$\mathcal O(log\,n)$$$, giving us a total complexity of $$$\mathcal O(n\, log^2 \, n)$$$

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +39 Проголосовать: не нравится

    An arguably easier way to get 100 on Arboras: Code an $$$O(q \cdot height)$$$ with various constant factor optimizations and breaks, most notably using hld dfs order to only have $$$O(n$$$ $$$log$$$ $$$n)$$$ cache misses and the unroll loops pragma. My first submission that wasn't WA only TLEd on test 8 of the last subtask, which I fixed by removing 1 array and slightly reducing the number of operations I do which allowed me to pass it in 2.871 s.

»
5 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +24 Проголосовать: не нравится

How to solve day1 problem3 Peru?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

how do you solve day2 problem1 ZeroSum?

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +12 Проголосовать: не нравится

    First of all, you must notice that the subarray between $$$a_i$$$ and $$$a_j$$$ has sum zero iff the sum of the elements between $$$a_1$$$ and $$$a_{i-1}$$$ is equal to the sum of those between $$$a_1$$$ and $$$a_j$$$. Hence we can reduce our problem to an easier one. We replace our array with its prefix sums array, i.e. $$$b_i=\sum_{j=1}^ia_j$$$. What we must do now is, for each interval, finding the maximum amount of pairs $$$f_i,s_i$$$ such that $$$b_{f_i-1}=b_{s_i}$$$ and the segments $$$f_i,s_i$$$ and $$$f_j,s_j$$$ don't intersect for every $$$i,j$$$ such that $$$i\neq j$$$. This is a quite known problem and can be solved greedily, by simply taking the pairs of equal elements which has the leftmost right element and repeating this process over and over until we reach the end of the queried segment. Although, this has a time complexity of $$$O(N)$$$ for each query, which gives TLE. We can speed up this procedure. For every index $$$i$$$ we store the minimum index $$$j \gt i$$$ such that $$$b_i = b_j$$$. This can be done easily in $$$O(NlogN)$$$ using a set. What we can do next is building a sparse table on those values and binary search the answer for each query. Unfortunately, using a standard sparse table causes MLE, so you must use a sparse table with a base greater than 2 (My solution using base 4 uses 20.0 MiB of memory, which is just enough to get 100/100). If you have any doubt feel free to ask.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

You never know true pain until you get 13 on bperm because you didn't try N^2 for subtask 2

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

My results: floppy — 28
bperm — 100
peru — 49
zerosum — 100
nicelines — 11
arboras — 100
total — 388

Personal opinion: I like problem bperm, but it completely ruined the contest. There are way to many people, who solved it with some O(N^2) solution + optimizations for subtask 3.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Wow I didn't know an RMI existed :O just knew of the RMM (math version).

Similar to RMM, is participation by the top individuals from the countries? And are they highschoolers like RMM?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Where can you download the tests/graders/upsolve the tasks?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

You can solve all problems here: https://oj.uz/problems/source/452