awang11's blog

By awang11, history, 2 months ago, In English
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.

  • Vote: I like it
  • +146
  • Vote: I do not like it

»
2 months ago, hide # |
 
Vote: I like it -7 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +29 Vote: I do not like it

i got goombah stompped

»
2 months ago, hide # |
 
Vote: I like it +39 Vote: I do not like it

WORLD 9

»
2 months ago, hide # |
 
Vote: I like it +30 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +23 Vote: I do not like it

Problem b strapped my soul from my body

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    I got stuck on it for two hours. I got the idea and the solution in my head, but the implementation... THE IMPLEMENTATION...

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Maybe you can try std::multiset, it's easy to use. I used only 459B to get AC.

      • »
        »
        »
        »
        2 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Thanks, JR_Oler. But how would multiset be used in this problem?

        • »
          »
          »
          »
          »
          2 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          My blog for multiset solution

          The key is observation of m*l ≤ 2e5. Specifically, is m,l ≤ 2e5.

        • »
          »
          »
          »
          »
          2 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          set & multiset has a function: if you traverse it using an iterator, you'll traverse the elements in increasing order.

          So just use multiset to maintain the $$$min(n,m-1)$$$ animatronics which have the largest $$$d_i$$$ s and other things are the same as the editoral.

          Apologize for my poor English.

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

It was..... traumatizing

»
2 months ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Completely messed up this contest.

»
2 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Just want to forget that I gave this contest lol.

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

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)

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

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

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      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(?)

      • »
        »
        »
        »
        2 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it +45 Vote: I do not like it

        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.

        • »
          »
          »
          »
          »
          2 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          Thank you very much! :) This is the answer that I wanted <3 Take my upvote ^^

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it +1 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +29 Vote: I do not like it

We apologize for the unexpectedly difficult B

you mean D

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

it was... traumatizing(2)

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 2  
Vote: I like it +3 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 2  
Vote: I like it +24 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

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!

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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';
    }
    
}
»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it
    void solve()
    {
        ll n,m,l;
        cin>>n>>m>>l;
        V a(n);
        scan(a,n);
        multiset<ll> f;
        for(ll i=0;i<min(m,n+1);i++) f.insert(0);
        ll i=0;
        for(ll t=1;t<=a[n-1];t++)
        {
            auto it=f.begin();
            ll val=*it;
            f.erase(it);
            //cout<<val+1<<endl;
            f.insert(val+1);
            if(a[i]==t)
            {
                auto it=f.end();
                it--;
                f.erase(it);
                i++;
                ll left=n-i+1;
                if(left==f.size()) continue;
                f.insert(0);
            }
        }
        auto it=f.end();
        it--;
        ll ans=*it+l-a[n-1];
        cout<<ans;
    }
    

    as O(xlogx) also would pass where x=m*l and this is much small and simple code

»
2 months ago, hide # |
 
Vote: I like it -8 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    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?

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      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..

»
2 months ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

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.

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    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).

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it +13 Vote: I do not like it

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

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it +31 Vote: I do not like it

      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.

»
2 months ago, hide # |
 
Vote: I like it +8 Vote: I do not like it

B as in "Brutal"

»
2 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

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.

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I just have to say

orz we12223 for going to blue:)

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

messed up this round B was traumatizing :(

»
2 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

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

more importantly:
»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
    Rev. 4  
    Vote: I like it +4 Vote: I do not like it

    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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 4  
Vote: I like it +26 Vote: I do not like it

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)

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

im dead

»
2 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Div 1 + Div 2 vs Div 1

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

B isn't B

»
2 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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

365958320

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

wasnt it a dijkstra for third problem?

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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!

»
2 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Problem D

    "Why did we ask for only vertex v, and not for all nodes?"

    -Is it because if you asked for all nodes, contestants would easily guess the Tree DP approach? Or is there another reason?

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it +4 Vote: I do not like it

      The tree DP no longer works if you ask for all nodes, actually! It’s quite important that you get no updates from “above you” in the tree. When you ask for a single node, you don’t worry about paths passing through v, because if you find one, you’re done anyway!

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

is this possible with accurate hitboxes?

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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 }

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    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.

»
2 months ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

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!!

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

https://mirror.codeforces.com/contest/2207/submission/366018299

it'll be a huge help

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Your divide and conquer approach is wrong. Consider this testcase:

    1

    14 10

    6 10 6 10 6 10 6 6 10 10 10 5 10 5

    Your code will output 10, However optimal answer is 13.

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    for i in range(1,n-1): if (s[i-1] == '1' and s[i+1] == '1'): s[i] = '0'

    for i in range(1,n-1): if (s[i-1] == '1' and s[i+1] == '1'): s[i] = '0'

    same loop twice

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

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.

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

awang11

2207C/Solution

Spoiler
»
2 months ago, hide # |
Rev. 3  
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

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

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    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

  • »
    »
    2 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    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

    • »
      »
      »
      2 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      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$$$.

      .

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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.

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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 ?

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Problem F can be solved by flow.

code

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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)?

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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.

»
2 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

well done

»
4 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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?

»
2 hours ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why they always make long story statements