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

Автор E869120, 2 месяца назад, По-английски

Hello, everyone!

Japanese Olympiad in Informatics (JOI) Final Stage 2026 (Contest URL) will be held from March 21st to 24th. There are 4 days in the contest. Note that the Final Stage is a kind of IOI selection camp, which is equivalent to Spring Training in 2025 or before.


The contest information is as follows. Details are available in contest page.

  • Number of problems for each contest: 3-4 problems
  • Style: IOI-Style (There may be some partial scores)
  • Problem Statement: Japanese & English
  • There may be some unusual task (e.g. output-only task, communication task) like IOI

The registration page and live scoreboard will be announced 10 minutes before the contest.

We welcome all participants. Good luck and have fun!


UPD1: The first contest will start in 8 hours.
UPD2: Contest Day 1 is started.
UPD3: Contest Day 1 is ended. You can discuss the problems.
UPD4: Contest Day 2 is started.
UPD5: Contest Day 2 is ended. You can discuss the problems.
UPD6: Contest Day 3 is started.
UPD7: Contest Day 3 is ended. You can discuss the problems.
UPD8: Contest Day 4 is started.
UPD9: Contest Day 4 is ended. You can discuss the problems. Thank you for participating in this event.

Теги joi, ioi
  • Проголосовать: нравится
  • +297
  • Проголосовать: не нравится

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

Is there an error in the scoreboard?

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

When/where can the problems be discussed?

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

Where can we upsolve the problems ?

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

How to solve multi? I can't get anything better than $$$log_2{N}+2 = 10$$$

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

    The goal is calculating MST weight of the complete graph. A natural first idea is to just run Boruvka until only one component remains: in each round, every vertex sends its cheapest edge leaving its current component, and from all those messages everyone can reconstruct one full Boruvka phase and the new contracted graph. But this requires $$$\lceil \log_2 N \rceil + 1$$$ rounds.

    A 7-round solution:

    • Rounds 1 to 4: run Boruvka. In each round, every vertex sends its cheapest edge leaving its current component. From all N messages, everyone can reconstruct the whole Boruvka phase, contract components, and relabel them. After 4 phases, the number of components is at most $$$\lceil N/16 \rceil \le 16$$$.

    • Round 5: now work on the quotient graph of those remaining components. Since there are at most 16 components, there are at most $$$16 \choose 2$$$ $$$=120$$$ component-pairs. Assign one recipient to each pair $$$(a,b)$$$. Every vertex in component $$$a$$$ sends to that recipient its own cheapest edge into component $$$b$$$, so the recipient can take the minimum and recover the exact edge weight between components $$$a$$$ and $$$b$$$. (If $$$N \lt 120$$$, there are at most 8 components so it works; it works in the same way for smaller $$$N$$$)

    • Round 6: each pair-recipient forwards its computed quotient-edge weight to contestant 0. Contestant 0 also carries the total weight already fixed during the first 4 Boruvka phases.
    • Round 7: contestant 0 now knows the full quotient graph on at most 16 nodes, computes its MST, adds the saved Boruvka total, and outputs the final answer.
    • The only bookkeeping detail is the running MST sum. Contestant 0 keeps it across rounds by using its message to recipient 0 as a private state channel, while still sending ordinary Boruvka information to the other recipients.

    I don't have 6-round solution; wonder how to do it (94 points seems possible in similar approach)

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

      hint: $$$1 \to 3 \to 6 \to 12 \to$$$ contract components

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

Does anyone know the intended time complexity for subtask 4 ($$$n \lt = 5000$$$) of day 1 problem 2 (garden)? I have a $$$O(n^2log(n))$$$ solution that TLE's on it.

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

Does anyone want to explain their approach to dangos and gardens?

  • »
    »
    2 месяца назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +21 Проголосовать: не нравится
    Dangos
    Gardens
»
2 месяца назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

How to solve casino and teleporter?

  • »
    »
    2 месяца назад, скрыть # ^ |
    Rev. 4  
    Проголосовать: нравится +23 Проголосовать: не нравится
    Casino
  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Do you know how to solve JOI Tour?

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

      I only know how to solve Subtask 1~8, don't know how to solve the whole problem.

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

        What was your solution(s) for subtasks 1 — 8?

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

          First consider a brute force for chain: $$$u = 1, 2, \dots, n$$$
          (in this order!) for every path that contains $$$u$$$, for every other nodes $$$v$$$ lie on the path, let $$$c_{a_v} \leftarrow c_{a_v} + 1$$$, then for $$$k = 1, 2, \dots, q$$$, let $$$ans_i \leftarrow c_{b_k - a_u}$$$, and the complexity is $$$O(nm + nQ)$$$, this can pass Subtask 2,6,8.

          We can split into $$$\sqrt{n}$$$ blocks and change the update-query complexity to $$$O(\sqrt{n})-O(\sqrt{n})$$$ and can pass $$$Q = 1$$$.

          For tree, we can use euler order to reduce the problem to chain.

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

            In the case of a tree structure, is your Euler sequence something like $$$(v_1, +1), (v_2, +1), (v_2, -1), (v_3, +1), (v_3, -1), (v_1, -1)$$$...?

            I ask this because, during the contest and now, I haven't been able to find a way to represent a path with just a single interval. Does each path consist of a combination of two intervals, such as $$$[tin[lca], tin[s]]$$$ and $$$[tin[next(lca)], tin[t]]$$$?

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

              For the path $$$u,v(in_u \lt in_v)$$$, if $$$u$$$ is not an ancestor of $$$v$$$ and we use our unchanged euler sequence, $$$u \to u'$$$ will have a coefficent of $$$-1$$$ and $$$v \to v'$$$ will be $$$1$$$, then we multiply $$$[out_u,out_{u'}]$$$ by $$$-1$$$ can fix this issue.

              $$$u'$$$ is the second vertex from $$$\text{lca}(u,v)\to u$$$, same for $$$v'$$$. There is still only $$$O(1)$$$ ranges.

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

        for the final subtasks, i believe a well-implemented $$$O(n (mq)^{0.5})$$$ passes (I implemented that for the line case)

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

      For chain scenario, decompose the chain into blocks of length $$$\sqrt n$$$, for each whole block in a path, it can be paired with elements in $$$O(1)$$$ intervals in this path, and you calculate this for each block separately, in $$$O(nq+m\sqrt n+n\sqrt n)$$$ time. For partial blocks, we need to calculate ways to pair element using one from $$$[l_1,r_1]$$$ and $$$[l_2,r_2]$$$ each, and the length of the intervals are $$$O(\sqrt n)$$$, so you do sweep line and brute force add all elements in $$$[l_2,r_2]$$$ at time $$$l_1$$$ and exclude them at time $$$r_1+1$$$, also in $$$O(m\sqrt n+nq)$$$ time.

      Tree scenario is just chain + euler tour.

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

      Thank you for your solution!

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

      Thanks for the detailed explanation!

      A few questions
      • »
        »
        »
        »
        2 месяца назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится
        reply
»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is there a different way to solve teleporter than using DP + aliens trick?

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

Why https://cms.ioi-jp.org/ Display 502 Bad Gateway?

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

Could anyone share their solutions for Day 3?

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

    Sorry, I don't really feel like describing Rainfall right now.

    Scarecrow
    Stamps
»
2 месяца назад, скрыть # |
Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

This is a solution idea for Voltage, could someone verify that it's correct?

EDIT: Seems to be correct, I just got AC with this.

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

How do we solve Baker? I can't think of anything better than range queries on a merge-sort tree of convex hulls which would give $$$O(\log^2(m))$$$ or something per query, which is probably too slow to AC.

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

    By sorting queries, they take amortized $$$O(1)$$$ per node, which is $$$O(\log m)$$$ amortized per query.

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

      Holy crap yeah, that's incredibly straightforward! Thank you.

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

      Could you please give me more information?

      I tried this: Each query only had one prefix, and it was always best to take a suffix of that prefix so we could do a binary search. We could take $$$x$$$ to $$$y$$$ if $$$B+(i-x+1)A \le T_i+L$$$ when I rearranged the equation, $$$T_i+(i+1)A \le Ax-B+L$$$. The left side could be calculated with a convex hull, and the right side is $$$O(1)$$$. Then I could get 60 points with $$$O(log^2 m)$$$, which means $$$T_M \le B$$$. I tried something like merge-sort tree on convex hulls and sorting the queries, but it was also $$$O(m log^2 m)$$$ and it didn't do any subtasks except the first and second.

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

        For each node in the merge-sort tree, we build a monotonic CHT. We partition each $$$[l,r]$$$ into $$$O(\log(m))$$$ many ranges, and maintain a vector of all the queries associated with each segment tree (or merge-sort tree) node. This allows us to answer all queries for a given node in amortized $$$O(1)$$$ time. While building up, we also run merge sort to sort the lines.

        It is not necessary to sort $$$\text{seg}[v]$$$ for each query, we can pre-sort all queries according to their $$$a$$$ value, so the complexity should be $$$O((m+q) \log(m))$$$.

        Although, even I TLE everything except the first two subtasks with this approach.

        EDIT: I managed to get 82 points (so the 22 point subtask) by using long double instead of __int128_t

        EDIT 2: Got AC! Turns out I didn't even need the merge sort because lines were already sorted by slope :facepalm:

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

          I'm not sure if I understand how you answer queries when you have a bunch of lines

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

            If your queries are monotonic: so something like $$$x, x+1, x+2$$$ or even $$$x, x-1, x-2$$$, we can answer queries while popping lines (which are sorted by slope themselves) from the front/back and don't need to perform a binary search to find the best line. Instead, we simply evaluate the last/first (depending on how queries are sorted) line against the line before that, and if the other line before does better, we pop the last line.

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

          I also cant get the last subtask even when my code is (m+q)logm :(

          My code runs in 0,7 seconds in the 22 point subtask how fast is yours?

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

Thanks for the problems. Some of them felt pretty annoying especially Rainfall and Festival, but I enjoyed the contests as whole.

I made all my implementations (except JOI Tour, i am yet to solve that) public on Github