Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

MridulAhi's blog

By MridulAhi, 20 months ago, In English

Hello Codeforces!

The Algorithms and Coding Club, IIT Delhi (ANCC) in collaboration with Tryst, IIT Delhi invites you all to participate in ICPC-de-Tryst 2025.

ICPC-de-Tryst is an ICPC-style team contest, featuring challenging algorithmic problems to be solved in a span of 4 hours, for teams of up to 3 members.

Join this WhatsApp group for more updates.

The problems were prepared and tested by Proelectro444, Soumil69, VijayBalaji, lucky__389, mayank69goel, ErrorAssassin, Azm1t, ghoul932, BladeRunner, etherinmatic, MridulAhi.

Prize Distribution

UPD1: Contest link

UPD2: The Contest is delayed by 30 minutes and will start at 19:30 IST due to registration issues at codeforces. Please register carefully this time, as registrations can't be changed due to some technical issue.

UPD3: Editorial

Good luck and happy coding!

ANCC, IIT Delhi

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

| Write comment?
»
20 months ago, hide # |
 
Vote: I like it +26 Vote: I do not like it

Contest clashes with cc starters.

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

Where's the contest link? when will it be visible??

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

team up?

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

Correct me if I am wrong, but for B, do we divide the array into blocks of size 2 * k and find answers in 3 * (k — 1) for each block? So it takes 3(n/k)(k — 1) operations that are less than 3n.

For each block, we find the aggregate for suffixes and prefixes in k — 1 operations for each half and merge answers from each half in at most k — 1 operations again.

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

    How do you find the required value for each subarray of length k using this? The intended idea is to partition the array in block sizes of k, and finding aggregate for each prefix and suffix of the block, after which we can find value for each subarray of length k in at most 1 query.

    • »
      »
      »
      20 months ago, hide # ^ |
      ← Rev. 3  
      Vote: I like it 0 Vote: I do not like it

      Same idea. I meant that we divide the array into blocks of 2*k, calculate prefixes of the right half of size k and suffix of the left half of size k, and merge in 1 query for all k-1 arrays for which we don't know the answer. btw, cool contest!

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

Can Someone pls Provide Hints/Solution of A.

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

    Since a diverse subarray contains at most $$$500$$$ distinct numbers, any element’s frequency is at most $$$500$$$ in it. Iterate over $$$r \in [1,n]$$$. Maintain a set $$$\mathcal{S}$$$ that stores the last index where each element in the current prefix $$$[1,r]$$$ appears. Maintain an array of length $$$501$$$ where the entry for $$$y$$$ stores the largest index $$$l'$$$ such that $$$\text{max_freq}[l',r] \ge y$$$. Iterate over ranges of $$$l$$$ with fixed value for distinct numbers ($$$x$$$) in $$$[l,r]$$$ using $$$\mathcal{S}$$$. Take the intersection of this range with the range where $$$\text{max_freq} \le x$$$ and add it to answer. The overall time complexity is $$$O(n \log n + n \cdot \max(a_i))$$$.

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

What's the intended solution of problem C?

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

    Greedily remove subtrees of size $$$\geq k$$$ from the bottom of the tree. Tree is decomposed into chains using HLD to maintain subtree sizes. $$$O(n/k)$$$ segment tree operations are needed to find the value for each $$$k$$$ so overall time complexity is $$$O(n\log^2 n)$$$.

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

      Can you explain how this is $$$O(n * log^2 n)$$$ ? , I simulated this obvious greedy using HLD but my complexity seems to be $$$O(n * log^3 n)$$$ because you remove at most $$$O(n * log n)$$$ edges and for each edge HLD update is $$$O(log^2 n)$$$

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

        Only the chain having the root of the removed subtree needs to be updated. When a chain is no longer useful, then add its remaining node count to its parent chain.

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

          Oh thanks i didn't notice this approach, although I optimized my $$$O(n * log^3 n)$$$ a little bit so it passed but with 3999 ms :P (TL is 4 secs)

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

is K designed to have tight memory but generous TL?

I can't get rid of MLE on test 36, tried all sorts of memory optimization but can't

Intended is Virtual/Auxiliary tree right?

https://codeforces.me/gym/595453/submission/310268897

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

Please provide your ANCC club (IIT Delhi) codeforces group link, so that we can solve such more interesting contests.