yud08's blog

By yud08, history, 4 hours ago, In English

Thank you so much for participating in our round! We really hope you enjoyed it. For us, it was an amazing and educational experience, and we look forward to the possibility that we could one day help to or hold a round again. Thanks again to abc864197532 and Vladithur for making the process so smooth and enjoyable.

2027A - Rectangle Arrangement

Tutorial
Code

2027B - Stalin Sort

Tutorial
Code

2027C - Add Zeros

Tutorial
Code

2027D1 - The Endspeaker (Easy Version)

Tutorial
Code

2027D2 - The Endspeaker (Hard Version)

Tutorial
Code
Tutorial (Segment Tree)
Code (Segment Tree)

2027E1 - Bit Game (Easy Version)

Tutorial
Code

2027E2 - Bit Game (Hard Version)

Tutorial
Code
  • Vote: I like it
  • +33
  • Vote: I do not like it

»
3 hours ago, # |
  Vote: I like it -72 Vote: I do not like it

D1 is the worst problem i've seen in recent times

»
3 hours ago, # |
  Vote: I like it +7 Vote: I do not like it

Problem B is very tricky.

»
3 hours ago, # |
  Vote: I like it +4 Vote: I do not like it

Good to know my first approach to 2027B was nlog(n). I couldnt think of O(n^2) solution for some reason.

»
3 hours ago, # |
  Vote: I like it +13 Vote: I do not like it

B and C were pretty good problems...D1 felt like a common DP problem

»
3 hours ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

Can anyone explain why changing map to unordered_map in 2027C - Add Zeros causes a TL?

I even took the solution from the editorial and ended up with a TL.

Editorial solution with unordered_map 288191624 (TL 16)

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

    Worst case access for unordered_map is O(n), whereas worst case for ordered_map is O(log n). In unordered map, the values are stored in buckets modulo a big number. If the input is constructed in such a way that all elements get stored in the same bucket, the worst case time complexity to access a single element becomes O(n). Hence, causing the TLE

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

    test cases are made in such a way that they cause collisions , as the worst time complexity is O(n) so it can't pass. If you still want to use hashmap you would have to make your own hash function. https://codeforces.net/contest/2027/submission/288190713

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

    One way to bypass this issue is to declare a custom_hash. The worst case time complexity for this still remains O(n), but you could atleast pass the current input values since you can use a random number generator to hash the values. Add the following piece of code and let me know if it passes or not.

    struct custom_hash {
        static uint64_t splitmix64(uint64_t x) {
            x += 0x9e3779b97f4a7c15;
            x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
            x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
            return x ^ (x >> 31);
        }
     
        size_t operator()(uint64_t x) const {
            static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
            return splitmix64(x + FIXED_RANDOM);
        }
    };
    
    unordered_map<int, int, custom_hash>
    
    
  • »
    »
    2 hours ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Thank you for your replies!

    I also found this amazing post explaining that.

    Blowing up unordered_map, and how to stop getting hacked on it

    • »
      »
      »
      100 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yeah, that's a great post. In the last contest, my submission to D was hacked for the very same reason..so this time, I made a custom hash function to minimize the risk of collisions for my solution to C

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

problem B

4

1 1 3 2

if we apply stalin then 2 will be automatically deleted and now we just have to remove 3 , then the resultant array will be 1 1 . The answer should be 1 .

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

    You have to remove some/none of the elements then apply operations on resulting array.

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

Thanks for fast editorial

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

B was really difficult to analyze (for me); Only able to solve A ,hoping to perform better in upcoming ones.

»
119 minutes ago, # |
  Vote: I like it +1 Vote: I do not like it

If anyone could explain D2 to me in detailed manner would be really helpful, thanks in advance..

»
119 minutes ago, # |
  Vote: I like it +1 Vote: I do not like it

can anyone please outline the two pointer approach for D1?

»
100 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Can we solve B using Monotoic Stack to find the maximum sub array that have the first element is largest? Time complexity will be reduce to O(n)?

»
75 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Having an answer be 0 mod 1e9+7 for D2 is kind of crazy

»
60 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Why my solution for Question C getting TLE

My solution 288152538

»
49 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Problem c have also another solution