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

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

Hi all,

The second contest of the 2022-2023 USACO season will be running from January 27th to January 30th. Good luck to everyone! Please wait until the contest is over for everyone before discussing anything contest-related (including but not limited to your scores or anything about the problems).

For those unfamiliar with the USACO contest format, please refer to the contest instructions and rules. We provide a short FAQ but folks should read all the rules carefully.

I have a question about the contest. Where do I ask it?

Email the contest director via the instructions above. Do not post anything publicly about the questions (including but not limited to your scores, how you felt about the problems, any content of the problems, etc) until after the contest is over for everyone. Do not DM me or anyone else affiliated with USACO, only the contest director can assist you. The contest director does not monitor Codeforces, this blog post is merely a courtesy to inform other people of the contest.

When can I enter the contest?

The contest will open on January 27th. A link to the contest will be posted here shortly after the contest opens.

If I submit multiple programs, which one gets evaluated?

Only the last submission will be evaluated for official scoring purposes.

Can I use prewritten code / templates?

No.

Am I allowed to use outside resources during the contest?

You may only refer to language documentation.

Why didn't I get an email from USACO when I registered my account?

Follow the directions on the USACO website regarding Gmail Delivery Issues to contact the contest director.

Can I solve problems in Rust?

No, the only languages supported are C, C++, Java, and Python. Consult the instructions for language-specific technical details.

Will Rust support be added?

Petition IOI to add Rust support first.

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

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

Hopefully I can get Gold this time around. Edit: Got it!

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

pain

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

plat pleaseeeeeeeeeeeee it has been way too long :sob:

would kind of sucky if 16 points away from cutoff again :((((

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

to clear the Bronze, what should be the rating on CF? please reply um noob

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

First time plat contestant here. My goal last month was to score 1000 in USACO; have to adjust that number to 100 now xD

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

Gold is too hard for me and I will try the problems of silver too.

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

I can only speak for silver, but who has noticed that the people writing the contests are different than last year? Perhaps this explains the variability in the problems and why they are more ad-hoc.

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

    From initial post :

    ****Do not post anything publicly about the questions (including but not limited to your scores, how you felt about the problems, any content of the problems, etc) until after the contest is over for everyone.

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

As of 1 hour ago it is January 31 UTC-12 so it is okay to discuss the contest now I believe. Did anyone who solved silver 1 have the idea to count cycles in the directed graph of letters? I implemented this over and over for two hours but couldn't pass any tests. Trying to figure out if my idea was wrong or my implementation was wrong.

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

Hi, I still had an hour left on my clock when I was doing my gold contest but it ended. Is it normal (I started too late) or is it an error ? Anyway, it does not matter since I am not in any country's IOI preparation. But I was about to submit two bruteforces and grasp some more points haha.

edit : Also, I really enjoyed the problems (I was able to see the silver and gold ones!)

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

Ideas for the first problem in gold?

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

    Were you able to solve the second one (light and switches one) ? I couldn't come up with any proper strategy to make both the strings equal in minimal moves :(

  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится
    Here is O(N^2) solution:
  • »
    »
    3 года назад, скрыть # ^ |
     
    Проголосовать: нравится +6 Проголосовать: не нравится

    I got full score by making a tree using pointers and some small optimisations

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

Hi,
Is there any silver participant who ACed P1.
Please share your ideas.
I Aced P2 and P3 but messed up p1.
It seems I was way behind the intended solution.
At a first glance it was obvious that problem will revolve around cycles but I messed up after that.

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

    I didn't get P1 completely, only getting a 10/15. However, I'm pretty sure I found the bug in my implementation and that the approach is correct. Basically create a graph between character types where character c1 has a directed edge to c2 if c1 is in the input string and wants to reach c2 in the output string. Observe that each node (a distinct character type) must have an outdegree of at most 1. Otherwise, there's no way to do it. Once you know that the graph is valid, note that the answer is simply the #of edges (not including self-loops) assuming there are no cycles (not including self-loops). If there are cycles, that complicates the solution a little bit. It turns out you'll need to turn one node in the cycle into another character. If any node in the cycle has a child, it's optimal to increase the answer by the length of the cycle, since there's guaranteed to be a valid construction. Otherwise if there's another node that isn't part of any cycle, we can use that and increase the answer by the length of the cycle + 1. Otherwise, it's impossible to fix the cycle. May post some code later, but I need to grab some sleep.

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

Posting a neat solution to Plat P1 here

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

Solution to plat p2 or p3?

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

    P2: For the first subtask, we can use bitmask DP to solve each query independently. Let dp[m][v] be the maximum mana we can achieve if we visit the fountains represented by the bitmask m, finishing at vertex v. To transition, we can take a path ending at v and append some unvisited vertex u to the end, thus going from dp[m][v] to dp[m|(1<<u)][u]. This changes the resulting mana quantity in two ways: it increases by s * M[u], the mana we consume from u, but forces us to visit all vertices in M earlier, decreasing our total mana by D[v][u] * T[m], where D[v][u] is the length of the shortest path from v to u and T[m] is the total mana accumulation rate summed over all fountains in m. Computing this DP for each query and choosing the maximal dp[m][v] for our end vertex v is sufficient to solve the first subtask.

    To solve the next few subtasks, we will compute the DP only once. The idea is that the only part of our transitions which depend on s is adding s * M[u], which happens once for every u in our mask m. Thus, we can ignore this part of our transition when computing our DP. Then, for each query, we can choose m to maximize s * T[m] + dp[m][v]. We still must iterate over every mask for each query, but we no longer have to compute the DP for every query.

    To get full points, we observe that the functions s * T[m] + dp[m][v] corresponding to each bitmask are linear in s. As such, each query reduces to finding the maximum value of a set of linear functions at a point, and this is a standard problem which can be solved using the convex hull trick.

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

    I have a different and shorter to code solution to P3. It is optimal to choose a path going up starting at a leaf, where at each node in the path the whole subtree is colored, then choose a path going down to a leaf when uncoloring. The cost of this operation is $$$2 \cdot sub_u$$$, where $$$sub_u$$$ is the subtree size of $$$u$$$ and $$$u$$$ is the top node in the path.

    We can make $$$dp_{u, k}$$$ as the minimum cost for a subtree $$$u$$$ where there are $$$k$$$ paths to be used. $$$k$$$ can be $$$1$$$ or $$$2$$$. We denote $$$x$$$ as $$$\sum_{}^{} (dp_{v, 2} + sub_v)$$$, where $$$v$$$ is a child of $$$u$$$. To calcuate the $$$dp$$$ values, we can create $$$cand$$$, which stores the maximum $$$2$$$ values of $$$dp_{v, 2} + sub_v - dp_{v, 1}$$$ in decreasing order. This acts like giving a path to node $$$v$$$.

    $$$dp_{u, 1} = x - cand_0$$$

    $$$dp_{u, 2} = min(dp_{u, 1}, x - mx, x - cand_0 - cand_1)$$$, where $$$mx$$$ is $$$max(sub_v)$$$, which is basically giving both paths to $$$1$$$ node.

    The answer is $$$2 \cdot (dp_{1, 2} + sub_1)$$$.

    Code