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.
# | User | Rating |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Name |
---|
Good luck to all!
I think the contest is over right? How did you all do?
I don't think we can discuss that right now, we can discuss scores and problem questions when the USACO website tells us that the contest and over and it shows the solutions for the problems.
When I posted the comment, the USACO website already said that "the contest is over and they are compiling the results".
How to solve the geometry problem from Gold?
I think it’s dp right? I didn’t manage to get it during the test tho.
yes, it's dp.
Could you pls share code or somethn?
Code
If I haven't misinterpreted, the above solution is O(n^5), here is an O(n^4) solution: Code
The solution does some math to speed up the transitions by a dimension, though it actually doesn't run that much faster than O(n^5) solutions. This is probably because the transitions are more complicated. If I knew O(n^5) would've passed I would've coded that instead :/
Shoutout to Benq for setting easier problems :)
Do you think 730 would be able to qualify for plat?
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.
I think it’s temporarily unavailable because they are still calculating the result. It probably will be open again after a few days and you can find it under “contest”.
My solutions for platinum:
We want to count triples $$$(L, M, R)$$$ s.t. $$$L < M < R$$$ and $$$A_L$$$, $$$A_M$$$, and $$$A_R$$$ is unique in the subarray $$$[L, R]$$$.
Fix $$$R$$$. We keep a segment tree, where the $$$i$$$-th leaf in the segment tree has the number of pairs $$$(i, b)$$$ ($$$i \leq b$$$) s.t. $$$A_i$$$ and $$$A_b$$$ is unique in the subarray $$$[i, R]$$$. Note that if $$$A_i$$$ is unique in the subarray $$$[i, R]$$$, then $$$\text{segtree}_i \geq 1$$$ ($$$(i, i)$$$ is a valid pair).
Let $$$\text{prv}(i)$$$ denote the greatest index $$$j < i$$$ s.t. $$$A_j = A_i$$$.
Then the number of triples $$$(L, M, R)$$$ for a fixed $$$R$$$ is
We subtract $$$[\text{segtree}_i \neq 0]$$$ since $$$L < M$$$ must hold, thus we need to subtract the pairs $$$(i,i)$$$ if it is a valid pair ($$$A_i$$$ is unique in $$$[i, R]$$$).
Let's move from $$$R - 1$$$ to $$$R$$$.
We can do all operations above with a segment tree that supports:
Time complexity: $$$O(N \log{N})$$$.
Create an extra node labeled $$$0$$$ in the given graph.
Now we only need to count the number of eulerian circuits in a digraph, which we can do with the BEST theorem. The heaviest part of the computation is finding the determinant of an $$$N \times N$$$ matrix.
Time complexity: $$$O(T N^3)$$$.
We can decompose a subset into separate rows, where each row is a segment $$$[L_i, R_i]$$$. Then, the subset is valid if $$$[L_i, L_{i+1}, \dots, L_j]$$$ and $$$[R_i, R_{i+1}, \dots, R_j]$$$ is bitonic and the rows are contiguous.
Let $$$\text{dp}(r, c_1, c_2, b_1, b_2)$$$ be the number of configurations if the last segment is on the $$$r$$$-th row and spans from column $$$c_1$$$ to $$$c_2$$$. $$$b_1$$$ and $$$b_2$$$ denotes whether we have encountered the minimum (maximum) element in $$$[L_i, \dots, L_r = c_1]$$$ ($$$[R_i, \dots, R_r = c_2]$$$).
Then, if there is no empty cell between $$$(r, c_1)$$$ and $$$(r, c_2)$$$:
We can speed up the transition to $$$O(1)$$$ with prefix sums.
Time complexity: $$$O(N^3)$$$.
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.
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) < s(y)$$$, and $$$f(y) < s(x)$$$.
We can calculate the number of such pairs using a regular segment tree. In every node we store:
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.
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?
In each segment $$$[L, R]$$$ (of a node in the segment tree), we keep:
Then, if a we add $$$x$$$ to the segment $$$[L, R]$$$:
Everything else is almost the same as a standard lazy segment tree.
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.
A set is too slow for test case #10. You could use a 3-D array to store the states you have already visited.
Yeah that's what it says in the official solution.
It's still a bit sketchy though, because my solution takes about 0.33 seconds (and the official solution took 0.2), which is quite long. Maybe we could have had a limit of a 20 x 20 grid instead, but it's already over now.
USACO Gold Solutions:
That's all I solved fully (400 on this contest)
When do US Open/Finalist results come out?
(This won't affect me, but I'm curious)