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

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

Hi all,

The final contest of the 2020-2021 USACO season will be running this weekend. Good luck to everyone! Please wait until the contest is over for everyone before discussing problems here.

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

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

Good luck to all!

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

I think the contest is over right? How did you all do?

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

How to solve the geometry problem from Gold?

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

Do you think 730 would be able to qualify for plat?

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

Can anyone provide link to the problems for practice, since I am not able to find the link to the problems of US open on the USACO website.

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

My solutions for platinum:

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

    It's actually possible to solve routing in $$$O(KN^2)$$$ time, because the matrix you take the determinant of is almost upper-triangular. In particular, it's upper triangular for all but at most 2 rows, so if you do Gaussian elimination in the right order, you'll only have to do $$$O(KN)$$$ row-operations.

    Just for the record: I believe the intended solution does not involve the BEST theorem or determinants, and takes $$$O(N^{K+1})$$$ runtime. Essentially, we will just try to match all inedges and outedges at each vertex; there are $$$\prod deg(i)!$$$ ways to do this. Some of these matchings may form unwanted eddy cycles, which must involve one of the $$$K$$$ backedges. Then, we can count ways to form the cycles using these $$$K$$$ edges, and we'll end up with a DP with $$$O(N^K)$$$ states and $$$O(N^{K+1})$$$ runtime. In fact, you can use some determinant-like arguments (or inclusion/exclusion if you'd prefer) to transform this into computing some path counts in $$$O(N^2)$$$, followed by taking a determinant of a $$$K \times K$$$ matrix, which is essentially equivalent to the BEST theorem/Gaussian elimination solution.

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

    I just have a slightly different solution to united I'd like to share (the complexity is the same, but we don't need lazy propagation in segment tree for example).

    If we fix our $$$L = l$$$, let $$$f(i)$$$ denote the index of first occurrence of number $$$i$$$ to the right of $$$l$$$, and $$$s(i)$$$ denote the second occurrence. We can handle some of them being non-existing by just setting them to $$$n$$$.

    Then, we need to consider the interval $$$(l + 1, f(A_l) - 1)$$$ to search for two indices for $$$M$$$ and $$$R$$$. Obviously, as $$$A_M$$$ and $$$A_R$$$ have to be unique in the chosen subarray, they are going to be $$$f(x)$$$ for some $$$x$$$. The condition for some values $$$x$$$ and $$$y$$$ being a suitable pair of values is $$$f(x) \lt s(y)$$$, and $$$f(y) \lt s(x)$$$.

    We can calculate the number of such pairs using a regular segment tree. In every node we store:

    • the number of $$$f$$$ values
    • the number of $$$s$$$ values
    • number of $$$(i, j)$$$ such that $$$f(i) \lt s(j)$$$
    • number of $$$(i, j)$$$ such that $$$s(i) \lt f(j)$$$,

    which we can easily merge in $$$O(1)$$$. From these four values, we can get the number of pairs we need. Note that when we're moving our $$$L$$$, we only have $$$O(1)$$$ updates in the segment tree, so we end up with $$$O(N\log N)$$$ complexity in the end.

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

    For united, how do you construct that segment tree? In competition, I got to the point of figuring out that kind of a structure was necessary, but couldn't figure out how to actually build such a tree. How can you toggle an element's activity and target those elements specifically?

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

      In each segment $$$[L, R]$$$ (of a node in the segment tree), we keep:

      • $$$cnt$$$, number of active positions.
      • $$$sum$$$, sum of elements in active positions.
      • $$$lazy$$$, lazy propagation.

      Then, if a we add $$$x$$$ to the segment $$$[L, R]$$$:

      • Increase $$$sum$$$ by $$$cnt \cdot x$$$.
      • Increase $$$lazy$$$ by $$$x$$$.

      Everything else is almost the same as a standard lazy segment tree.

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

What was the approach for #1 in the silver division?

The tricky thing was that you can go back the way you came and retrace your steps, so what I did was have a sort of vis set that stores the grids we visited at each point in the maze. But that TLE'ed on test case #10, so I'm curious to know what other people did.

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

USACO Gold Solutions:

United

That's all I solved fully (400 on this contest)

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

When do US Open/Finalist results come out?

(This won't affect me, but I'm curious)