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

Автор awang11, история, 7 месяцев назад, По-английски
Trophy Presentations — Asuka Ota, Ryo Nagamatsu, Mario Kart Wii

UPD 1: added hints, problem credits, more specific acknowledgements and some remarks. Implementations are on the way, sorry for making y'all wait!

UPD 2: Implementations are finally here.

2207A - 1-1

Author: awang11

Preparers: awang11, IceSerpent

Analysis: awang11

Hint 1
Solution
Rate the problem!
Implementation

2207B - One Night At Freddy's

Author: awang11

Preparers: awang11, IceSerpent

(Cool) analysis: awesomeguy856

Hint 1
Hint 2
Hint 3
Solution
Implementation
Rate the problem!

2207C - Where's My Water?

Author: awang11

Preparer: IceSerpent

Analysis: IceSerpent

Hint 1
Hint 2
Hint 3
Solution
Implementation
Rate the problem!
Remark 1
Remark 2

2207D - Boxed Like a Fish

Author: awang11

Preparers: awang11, IceSerpent

Analysis: awang11

Hint 1
Hint 2
Hint 3
Hint 4
Solution
Implementation
Rate the problem!

2207E1 - N-MEX (Constructive Version)

Author: awang11

Preparers: awang11, IceSerpent

Analysis: awang11

Hint 1
Hint 2
Solution
Implementation
Rate the problem!

2207E2 - N-MEX (Counting Version)

Same credits as E1.

Hint 1
Hint 2
Solution
Implementation
Rate the problem!

2207F - Hanabi

Author: IceSerpent

Preparers: awang11, IceSerpent

Analysis: awang11, IceSerpent

Hint 1
Hint 2
Hint 3
Hint 4
Solution
Implementation
Rate the problem!
Remark 1
Remark 2

2207G - Toothless

Author: awang11

Preparer: awang11

Analysis: awang11

Hint 1
Hint 2
Hint 3
Solution
Implementation
Rate the problem!
Remark / Conjecture

2207H1 - Bowser's Castle (Easy Version)

Author: awang11

Preparer: awang11, IceSerpent

Analysis: awang11, IceSerpent

Hint 1
Hint 2
Hint 3
Solution
Implementation
Rate the problem!

2207H2 - Bowser's Castle (Medium Version)

Same credits as H1, main solution due to 244mhq.

Hint 1
Hint 2
Hint 3
Hint 4
Solution
Implementation
Rate the problem!
Remark

2207H3 - Bowser's Castle (Hard Version)

Same credits as H1, main solution inspired by IceSerpent and awesomeguy856.

Hint 1
Hint 2
Hint 3
Hint 4
Hint 5
Hint 6
Solution
Implementation
Rate the problem!
Remark 1
Remark 2

We apologize for the unexpectedly difficult B, but we hope you enjoyed thinking about the problems regardless!

Special thanks to Hori, nik_exists, awesomeguy856, shcal for their assistance with problems F through H3. We also acknowledge Amazed, chromate00, defnotmee, Noobish_Monk, awoo, misteg168, cduckling for sticking with us in copy-editing and improving statements up until the contest. Once again, a huge thanks to flummoxedfeline for making our round look beautiful. Without them this round wouldn't be complete.

Implementations will be added soon.

Разбор задач Codeforces Round 1085 (Div. 1 + Div. 2)
  • Проголосовать: нравится
  • +146
  • Проголосовать: не нравится

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

Auto comment: topic has been updated by awang11 (previous revision, new revision, compare).

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

i got goombah stompped

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

WORLD 9

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

Should have swapped B and C for the welfare of the barbarians :(

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

Problem b strapped my soul from my body

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

It was..... traumatizing

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

I know there were some of you multitasking Codeforces and watching India win the world cup, I was doing the same :D

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

The exam is more confusing than my life, and my mind is emptier than my wallet.

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

Completely messed up this contest.

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

Just want to forget that I gave this contest lol.

Also I just can't get it why for Problem C https://codeforces.me/contest/2207/submission/365898415 fails on test case3. Wasted 2 hr on this. Can anyone explain why is it wrong?

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

in 3 hour i managed to solve first 2 question. contest was hard but i got best rank so far.

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

Did you know that C can be solved in O(n*log(n)) time using range max query? I suspect there also O(n) solution but can't figure it out yet x)

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

    RMQ is replaceable by DSU here, so in $$$O(n \alpha)$$$ actually.

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

      Oh yeah, you're right, DSU is indeed and better than RMQ, thanks for the info :)

      Still wondering if O(n) solution exist, using sliding window or shuffling the queries, or maybe it's impossible and DSU is the best(?)

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

        I think we can do C in $$$O(n)$$$ with dynamic programming on cartesian trees without any observations. Split each node of the cartesian tree using the maximum value.

        $$$dp_{u,k}$$$ represents the maximum answer if we place $$$1 \leq k \leq 2$$$ drains in the range corresponding to node $$$u$$$ on the cartesian tree.

        The transitions are easy and doable in $$$O(1)$$$ because as long as $$$k \geq 1$$$, water corresponding to rows $$$\max(a_l, \ldots, a_r) + 1$$$ to $$$h$$$ will all be drained. Excluding those rows, the drains belonging to the left child's range won't affect the amount of water drained by drains in the right child's range (and vice versa), so the contribution from each child is independent. We can just sum up $$$dp$$$ values for the left and right children.

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

    Meanwhile me, who did in n^2 logn using RMQ

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

    can you please explain the logic behind the nlogn solution or the DSU solution

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

We apologize for the unexpectedly difficult B

you mean D

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

I wish I read E1 before D, wasted too much time there, was very close to solving E1 but the time ran out :(

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

in F editorial i think u guys forgot to change the names to iroh and zuko

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

Problem D was really very beautiful :D Thanks for the contest! Though B wasn't a B problem :(

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

it was... traumatizing(2)

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

Thank god I didn't get many WA on test 2 this contest...

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

In editorial of E1 i think you meant "Vacuously take a0=n". Cause "Vacuously take b0=n" does not make any sense.

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

am i the only person who found D easy (even though i spent embarrassingly long on the implementation)

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

Thanks for the competition! It was interesting. This is my first competition where I solved problem C in div 2. But I couldn't solve problem B. It felt like an animatronic had eaten my brains after C and now I couldn't solve it. It's interesting how I solved C: For each height a[i], I built a height map as follows: I went left and right, taking the maximum level from the current and the past. This is because we can't go down, but we can go up. Then I sorted by the total points, and took the first one (that is, the best outcome). Next, I made the following observation: It will be effective to add new places if we expand the maximum depth of the pits. For this reason, I went through all the arrays except the best one and built a new height map as the minimum height value from two pits. Then I just output the maximum value.

def main() -> None:
    t: int = int(input())
    for _ in range(t):
        n, h = map(int, input().split())
        a: list[int] = [*map(int, input().split())]
        dp = []
        i = 0
        while i < n:
            j = i - 1
            dp2 = a.copy()
            while j >= 0:
                dp2[j] = max(dp2[j], dp2[j + 1])
                j -= 1

            j = i + 1
            while j < n:
                dp2[j] = max(dp2[j], dp2[j - 1])
                j += 1

            i += 1
            dp.append(dp2)
        dp = sorted(dp, key=lambda x: sum(x))
        arr = dp[0]
        if len(dp) == 1:
            print(n * h - sum(arr))
            continue
        i = 1
        nums = []
        while i < n:
            arr2 = dp[i]
            nums.append(n * h - sum([min(arr[i], arr2[i]) for i in range(n)]))
            i += 1
        print(max(nums or [0]))


if __name__ == "__main__":
    main()

By the way, I made it to the competition after my newborn sister was discharged!

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

that was... idk, the problem B...

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

Hey people, I dont seem to understand that why does this logic fail in B. Please help :'(

void solve(){
    int n, m, l; cin >> n >> m >> l;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];

    if (m==1){
        cout << l - a[n-1] << '\n';
        return;
    }
    else{
        vector<int> b(n);
        b[0] = a[0];

        for(int i=1; i<n; i++){
            b[i] = a[i] - a[i-1];
        }

        int sum = b[0];
        vector<int> happy(2, 0);
        
        for(int i=0; i<n; i++){

            if (happy[(i+1)%2] <= b[i]){
                sum = happy[(i+1)%2] + b[i];
                happy[(i)%2] = sum/2;
                happy[(i+1)%2] = 0;
            }
            else{
                happy[(i)%2] = b[i];
                happy[(i+1)%2] = 0;
            }
        }

        int ans = max(happy[0], happy[1]);
        ans += l - a[n-1];
        cout << ans << '\n';
    }
    
}
»
7 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As much as i enjoyed solving B on paper, it took each and every brain cell to code it out

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

We can solve problem C in O(n log n) using divide and conquer. The top water (h — max(a)) will always be taken. Recursively solve left and right of the max position to find best first and second drains using the same idea.... left.first/right.first = max water by placing first drain in left/right segment. left.second/right.second = max water by placing second drain in left/right segment. At current position: ans.first = max(left.first, right.first). ans.second = if(left.first>right.first) max(right.first, left.second) else max(left.first, right.second).

unfortunately couldn't write the code in time xd

Code — 365906211

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

    idk why ure getting downvoted but i had the same exact thought. although i was tripping up when there are multiple equal maxxes, but i guess that doesnt matter?

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

      maybe for bad explanation xd no problem... and no same maxes wont matter... supposedly you entered the right. its max will be same as the parent. therefor the top_drain will be 0... as u wont take any water from the top part which is what should happend..

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

Why is nm <= 2*10^3 in the G problem when it's easy to achieve O(n*m*a(nm)) asymptotics using dsu? This is very confusing.

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

    I think they maybe want to mislead into thinking about more complicated stuff (for example the problem from first glance looks like it could involve some flows, and you cannot immediately disregard that because the constraints are low enough).

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

    The editorial solution iterates O(nm) times to cut a cycle each time, so this step was allowed to be O((nm)^2).

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

      I think the easiest way to implement that part is actually to add cells one by one in a specific order (first #, then x, then .), and loop over its neighbours to see if two of them are in the same component. This can be implemented with DSU.

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

B as in "Brutal"

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

Hello , can anyone please help me find what the error is in my code for B ? I am pretty sure it matches with the editorial solution , but getting WA at testcase 6.

365901772

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

I feel like problems A, B, C in this round are all about implementing the process rather than ad-hoc solutions, and they’re slightly harder to implement than in other rounds.

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

I just have to say

orz we12223 for going to blue:)

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

messed up this round B was traumatizing :(

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

My rating was falling consistently until this contest, but then the miracle happened: my rating went up, and what is

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

Why did this code for C got accepted . It is O(N) , cannot prove it , I just precomputed every sinks drain coverage then I sorted , i chose leftmost point with maximal drain coverage then fixing that point as Ci (refer editorial) I calculated Cj-Ck by taking max across each element wrt that fixed Ci ,i can't prove it why choosing leftmost maximal sink was optimal.

365915250

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

    You are sorting the value, so your solution is actually O(N*log(N)), but thank you for the idea! I could write strictly linear O(N) solution without any sorting: 365932645

    Proof:

    • Suppose the amount of water drained at index $$$i$$$ is $$$cnt_i$$$
    • Read the solution of editorial in this blog: the amount of water drained at index $$$i$$$ and $$$j$$$ is $$$cnt_i + cnt_j - cnt_k$$$
    • WLOG, let's assume $$$i\le j$$$
    • For each $$$k$$$ we can find maximum value by querying max of $$$cnt_i=\max(cnt_x,cnt_{x+1},...,cnt{k-1},cnt_k)$$$ and $$$cnt_j=\max(cnt_k,cnt_{k+1},...,cnt_{y-1},cnt_y)$$$ where $$$x$$$ is the smallest index and $$$y$$$ is largest index that satisfy $$$\max(a_x,a_{x+1},...,a_{y-1},a_y)=a_k$$$
      • If we use RMQ for querying the $$$cnt_i$$$ and $$$cnt_j$$$ value in the range for each index $$$k$$$ we can solve this problem in $$$O(n\log(n))$$$ complexity
    • Now we want to prove that if $$$cnt_i+cnt_j-cnt_k$$$ is largest, then either $$$cnt_i=\max(cnt_1,cnt_2,...,cnt_n)$$$ or $$$cnt_j=\max(cnt_1,cnt_2,...,cnt_n)$$$ is true by contradiction:
      • Let's assume both $$$cnt_i$$$ and $$$cnt_j$$$ is not equal to $$$\max(cnt_1,cnt_2,...,cnt_n)$$$
      • Then there is another index $$$m$$$ such that $$$cnt_m \gt \max(cnt_i,cnt_j)$$$
      • WLOG (we can flip the case by inverting the index $$$[1..n]$$$ to $$$[n..1]$$$), let's assume $$$m\le k$$$:
        • if $$$m\ge x$$$ then obviously $$$cnt_m+cnt_j-cnt_k \gt cnt_i+cnt_j-cnt_k$$$ because $$$cnt_m \gt cnt_i$$$ (contradict with statement $$$cnt_i+cnt_j-cnt_k$$$ is the largest)
        • if $$$m \lt x$$$ then we have new "pivot" $$$l$$$ such that $$$\max(a_m,a_{m+1},...,a_{y-1},a_y)=a_l$$$ note that $$$a_l \gt a_k$$$ by the definition and because $$$\max(a_l,a_{l+1},...,a_{k-1},a_k)=a_l$$$ then $$$cnt_k \gt cnt_l$$$ because draining index $$$k$$$ will indirectly also drain at index $$$l$$$, now we can see that the new drain value $$$cnt_m+cnt_j-cnt_l \gt cnt_i+cnt_j-cnt_k$$$ because $$$cnt_m \gt cnt_i$$$ and $$$cnt_l \lt cnt_k$$$ (contradict again with statement $$$cnt_i+cnt_j-cnt_k$$$ is the largest)
      • Therefore either $$$cnt_i=\max(cnt_1,cnt_2,...,cnt_n)$$$ or $$$cnt_j=\max(cnt_1,cnt_2,...,cnt_n)$$$ is true (Q.E.D)
    • So the implication of above theorem, we can find global maximum for both drainage $$$i$$$ and $$$j$$$ by finding the global maximum of draining only single index $$$c$$$ first, then we can guarantee that either $$$c=i$$$ or $$$c=j$$$ is true.
    • The algorithm then handle both cases and find the max in linear time by fixing $$$i=c$$$ and looping $$$j=i..n$$$ and fixing $$$j=c$$$ and looping $$$i=j..1$$$ because finding "pivot" $$$k$$$ can be done in $$$O(1)$$$ while iterating, then this solution is strictly linear $$$O(n)$$$.

    See again my implementation: 365932645

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

Auto comment: topic has been updated by awang11 (previous revision, new revision, compare).

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

My solution to F was pretty different from what the editorial did.

First, every card must be placed as a result of a color clue or a rank clue. Rank clues can pick up all cards of that rank, but color clues can only include intervals of ranks [l...r] such that the [l... r] is a subsequence of the ranks of that color, l is a prefix maximum, and there are no larger cards of the same color between the l and the r. So now I construct a bipartite graph where one partition are the "rank clues", and the other partition consists of the maximal intervals of ranks [l,r] for each color that can be gotten with a color clue. Then we add edges between any two vertices which have a card in common. Now the requirement is that for each card, you must take either the color clue or the rank clue corresponding to that card (we drop the requirement that l is a prefix maximum when l=r, for convenience), which is equivalent to finding a min vertex cover. With hopcroft karp this is O((mn)^3/2).

Implementation is quite short: 365890006

(Edit: the authors mention this in remark 2, oops)

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

im dead

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

So consistently when there is no grey/green testers B turns out like this, no hate (i didn't even participate), just happen to notice this

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

you can create a blog. And in the blog so that there is a suspicious decision, otherwise some people make it out of AI

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

Div 1 + Div 2 vs Div 1

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

B isn't B

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

Can anyone help me- on which test case my code is failing for in B

365958320

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

wasnt it a dijkstra for third problem?

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

I’m a beginner and I tried solving the problems during the contest, but I was only able to solve the first one. I got stuck on the second problem and eventually had to give up. After the contest, I tried to understand it by asking GPT/Claude, but even they couldn’t provide the correct solution.

Now I’ve looked at the tutorial, but it mainly explains the observations and intuition rather than the actual implementation. As someone who is still learning, it’s difficult for me to convert those observations into code.

Could someone please help by sharing the implementation or guiding how to translate the editorial’s idea into code? It would really help beginners like me understand the solution better. Thank you!

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

Could someone please provide the answers to the hints for Problem D?

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

is this possible with accurate hitboxes?

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

can any one help me about problem b { in my local system test cases answer is right but in same test cases codeforces compiler is givung wrong answer }

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

Auto comment: topic has been updated by awang11 (previous revision, new revision, compare).

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

In D, I am not able to understand why

1 5 2 3 5 4 4 3 3 2 2 1

gives "NO" as the answer, Can somebody please help me out?

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

    snlx will not act on first move, cyndl goes to 2, snlx then go to edge(2-1) amd stop cyndil om vertex 2 , now u can figure it out, basically , snlx will wait until cyndl is about to make a move that will make it win or reach a winning node, through this strategy, snlx will make sure cyndl will waste its move so that snlx can get charged.

    in the above TC, after reaching 2, if cydil tries to go to 5, it will again get stopped, and same again from there.

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

The given solution for C is superb, observing that the drain at the max height between i,j would drain all the intersecting water is awesome. I could figure out that we need to do sum-intersection but I did not observe the intersection part. Nice one!!

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

can anyone explain why my code is giving wa on test-case 4 for problem -C :

https://codeforces.me/contest/2207/submission/366018299

it'll be a huge help

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

awang11 i think there is some repetition of loop which is unnecessary in A.

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

Can anyone please explain the solution of E1 , mainly the construction idea.

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

In problem E1 the input

1

7

7 5 4 3 2 1 1

can be 6 7 5 4 3 2 0 a solution? maybe I am missreading something or doing something bad, but I think that is possible

Yep I was wrong.

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

awang11

2207C/Solution

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

In question B,How to distribute the danger levels till there are n — m — 1 flashes remaining

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

Why is upper bound in H3 equal to 3N-2? I have no idea how to find or proove that value

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

My approach to 2207E2 - N-MEX (Counting Version) (can be similar to editorial solution):

Firstly check, if there is any construction possible using $$$n - i$$$ <= $$$a_i$$$ <= n and $$$a_i$$$ <= $$$a_{i - 1}$$$.

If construction possible,

Array a looks like [x, x, x, ..., y, y, y..., z, z, ...] (x > y > z > ...).

When filling $$$b_i$$$s, when $$$a_i$$$ = x, all numbers (> y && < x) must appear. Also, there can be some numbers less than y (due to too long x block).

Now, we get to first index, where x -> y, i.e., we are standing at first index, idx, where, a[idx] = y. Let's say, there were (k1 + 1) cells where a[i] = x. From these k1 cells, we have to allocate some (x — y — 1) cells to numbers (y + 1, y + 2, ..., x — 1) in any order.

No. of ways for that: nCr(k1, x — y — 1) * (x — y — 1) ! .

Now, we have k1 — (x — y — 1) cells left for future (can be used for placing numbers less than y). I have used $$$gps$$$ variable for counting such cells. Thus, gps = $$$k1 - (x - y - 1)$$$ for now.

Now, we are at index idx, and let's calculate ways to fill $$$b_{idx}$$$. We can put any number that we have already placed in b, and numbers greater than y. Thus, (n — y) + k1 — (x — y — 1) ways to fill $$$b_{idx}$$$. {(n — y) = numbers above y, and (k1 — (x — y — 1)) = number less than y already placed due to long blocks).

Similarly, processing, we will get to first index, idx1, where a[idx1] = z. Now, new gps = (gps + idx1 — idx — 1). We have to allocate (y — z — 1) cells to numbers (z + 1, z + 2, ..., y — 1) in any order. Ways: nCr(gps, y — z — 1) * (y — z — 1) ! . gps will decrease by (y — z — 1) now.

You can process the whole array like this. If you have any confusion in the explanation or want any proofs, please ask.

Accepted submission: 366190115

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

in problem B how to get 19 in this testcase?

2 3 40
13 37

lets say from 0 — 13 seconds the danger levels are like this (can add 13 danger levels)

7 6 0

obviously i will reset 7

0 6 0

from 13 — 37 seconds (can add 24 danger levels)

15 15 0

i reset 15

0 15 0

37 — 40 seconds (can add 3 danger levels)

0 18 0

how to get 19?? or am i understanding the question wrongly?

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

    lets say from 0 — 13 seconds the danger levels are like this (can add 13 danger levels)

    5 4 4

    obviously i will reset 5

    0 4 4

    from 13 — 37 seconds (can add 24 danger levels)

    0 16 16

    i reset 16

    0 16 0

    37 — 40 seconds (can add 3 danger levels)

    0 19 0

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

    oh wait is it cause we can do

    0 — 13 seconds

    6 6 1

    reset 6

    0 6 1

    13 — 37 seconds

    15 15 1

    reset 15

    0 15 1

    37 — 40 seconds

    0 18 1

    overall danger = 19

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

      Wrong, Problem description said:

      "Let the overall danger be the maximum danger across all animatronics, i.e. $$$\max_{1\leq j\leq m}d_j$$$"

      So overall danger for 0 18 1 is 18 because $$$\max(0,18,1) = 18$$$.

      .

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

Is there a typo in C:

"Then, a water tile at location $$$(x, y)$$$ is drained if $$$m_{min(x, i),max(x, i)} \lt y$$$" (instead of $$$\leq$$$ in editorial)? Otherwise, water tile is at same level as dirt and can't be drained.

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

For problem c , i was able to AC a greedy solution such that one of the drains must be the single best drain, and then finding the second drain in this topology by subtracting the water sucked by the first drain. my code Been trying to get a proof for this but cant satisfy myself, anyone ?

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

Problem F can be solved by flow.

code

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

In B cant we always increase to only 2 enemies and at any checkpoint flash at max one(this way we will have maximum at end)?

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

I couldn't understand part of the solution of E2: "Call an index $$$i$$$ good if $$$a_i=a_i−1$$$ and bad otherwise. By definition, $$$|S_n|=n− \text{# of good steps}$$$." Consider this input $$$n=6$$$ and $$$a =$$$ {$$$6, 6, 6, 4, 3, 3$$$}, and this solution {$$$5, 2, 1, 5, 4, 0$$$}. Firstly, I ran this solution through the E1 judge & checked it's valid (& hand checked it too); and, we can see if $$$a_0=n=6$$$, there are 4 good steps according to definition $$$(i=1,2,3,6)$$$, so $$$|S_n|$$$ should have $$$6-4=2$$$ elements; but according to definition, $$$S_n =$$$ {$$$3$$$} since $$$3$$$ is the only value in $$$[0,6)$$$ excluding the values present in $$$b_1...b_6$$$: $$$(5,4,2,1,0)$$$. So $$$|S_n|=1$$$ in this example, which should break the formula. Please help me out! Thank you.

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

well done

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

I don't really understand why would you not construct b in the implementation of E1. you are make a tutorial and then doing it the most unclear way possible. Maybe you are saving memory, but in this case you are using a lot of prints, which is even worse, and slower. What's the point?

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

why they always make long story statements