__baozii__'s blog

By __baozii__, history, 6 weeks ago, In English

We hope you enjoyed the problems!

Rate the contest!

2209A - Flip Flops

Solution
Code (C++)
Rate the problem!

2209B - Array

Solution
Code (Python)
Code (C++)
Rate the problem!

2209C - Find the Zero

Solution
Code (Python)
Rate the problem!

2209D - Ghostfires

Solution
Code (C++)
Rate the problem!

2209E - A Trivial String Problem

Solution
Code (Python)
Rate the problem!

2209F - Dynamic Values And Maximum Sum

Solution
Code (C++)
Rate the problem!
  • Vote: I like it
  • -64
  • Vote: I do not like it

»
6 weeks ago, hide # |
 
Vote: I like it +2 Vote: I do not like it

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

»
6 weeks ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

Fast Editorial! Thx

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

Thanks for the nice problemset and fastest editorial!!

»
6 weeks ago, hide # |
Rev. 2  
Vote: I like it +20 Vote: I do not like it

I wish n q log n for E was allowed to pass lol I was going to do binary search with rolling hashes to find all the prefixes and then dp for each query

(I had IMO a simpler idea, dp[i] is the best way you can split 1...i (where 1 is relative to the start of each query), dp[i] can extend to dp[j] if substring i+1...j is a prefix; precalculate these (this is where I only thought of the n q log n rolling hash approach but one of my friends did it with Z function in n q) and then use sliding window to keep track of the best one)

»
6 weeks ago, hide # |
 
Vote: I like it -17 Vote: I do not like it

D is hard but an excellent problem!

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

nice problemset!

»
6 weeks ago, hide # |
 
Vote: I like it +11 Vote: I do not like it

A-C S P E E D F O R C E S

»
6 weeks ago, hide # |
 
Vote: I like it +65 Vote: I do not like it

E didn't seem that interesting or fun to me. You just had to know one algorithm and you also had to hope that your $$$O(nq)$$$ solution would just pass even though $$$nq \leq 10^8$$$ which is relatively high. There was almost no hard observation to do which I don't think is appropriate for E. Other problems were fine.

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

    yeah I did a different n*q algorithm with a rolling hash and it doesn't pass in Python :(. I wish the bounds were 10**7 instead

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

      Sadly i think you have to learn C++ to solve some of these problems.

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

        Yeah, I love codeforces so far but that's definitely my main complaint with it :(

        I'm more used to ICPC / Kattis style problems where they're lenient enough with time constraints for Python to almost always work, but for a couple contests in a row now here I've been blocked by Python. I can write in C++, I just prefer Python because I think it's far quicker to write, but perhaps I will have to set up a C++ template and always start with C++ for D and up from now on :/

»
6 weeks ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Why it's div1 in the title

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

Appreciate the fast editorial, but I'm struggling the solution even after reading it :(

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

Hi, it feels like I did the same thing as said in editorial for C but it does not pass cases can someone explain to me why?

https://mirror.codeforces.com/contest/2209/submission/367684792

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

there were weak test cases for problem 3. Lot of prolems who asked n queries in one loop and one in the last passed . example of one such case is 1002. it is not there where most of the test cases would have failed

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

    Do you mean like randomized algorithms? I thought the interaction was adaptive so if you tried to guess (e.g. for a fixed randomly generated array each query has a 1/4 chance of succeeding) the interactor could adversarially WA you

»
6 weeks ago, hide # |
 
Vote: I like it +46 Vote: I do not like it

I don't understand the solution for D, it feels like it is not written in English. Can someone write it more clearly please

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

    I had a different solution, this is mine:

    Assume for convenience that R >= G >= B

    If R > G + B + 1, then you're not going to be able to use all the Rs, since the most Rs you can pack is RxRxRxRxRxR which requires at least R-1 B/G chars.

    Otherwise, let's construct a sequence that uses every character.

    First write two sections GGGGGGGG (possibly empty, since G >= B) and GBGBGBGB.

    Since R >= G, we can definitely pad the first section GRGRGRGRGRGRGRGR, and then we'll have some number of Rs left that we need to spend on the GBGBGBGBGB section.

    Assume we have an even number of Rs left, if it's odd then we'll put one at the beginning and we're fine.

    Then turn GB GB GB GB GB into BRGR BRGR GB GB GB; each pair of Rs that you have converts a GB into a BRGR. We flip it so that the transition BRGRGB doesn't break the 2-gap rule.

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

      What was the intuition behind this solution? Like how did you approach the problem and end up with this construction? Did you draw small cases?

      • »
        »
        »
        »
        6 weeks ago, hide # ^ |
        Rev. 5  
        Vote: I like it +2 Vote: I do not like it

        The first obvious thing was the triangle inequality thing with the RBRBRBRBRGRGR. And then that gave me the idea to see if it's always possible to use everything in the general case. (At this point I was already suspicious thinking something like alternating letters might let me use all the letters.) However with the general case you might not have enough Rs, so the beginning of the string is going to look like RxRxRxRxR end of the string is going to have to look like BGBGBG. So that gave me the idea of splitting the G/B characters into the "solid" section BBBBBB and the alternating section BGBGBGBG.

        Then finally the specific construction with the even/odd parity and pairing and stuff comes from playing around with it a bit and trying to formalize something that always works. [This part is not as hard as it looks, it just comes from BGBGBGBG I'm going to have to pack with Rs for the first half so I first try the standard BRGRBRGR BGBGBG but oh no that violates the every-3 condition, but I can flip the order to keep it straight, now let me just be careful with even/odd parity and write it a little more formally.]

        In general with constructions I think it can be helpful to prove an upper bound and then see if you can always construct a solution to hit it.

  • »
    »
    6 weeks ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    It is quite clear if you read the code. Basically you should be thinking in segments of 2, not in segments of 3 as the problem might imply. Cool solution but quite hard to find IMO.

    Here's my implementation which is basically same as edi

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

I was disappointed with B since it allowed n^2, but C made up for everything. C==Cool

»
6 weeks ago, hide # |
 
Vote: I like it +33 Vote: I do not like it

I came up with a very clean implementation for D

»
6 weeks ago, hide # |
Rev. 2  
Vote: I like it +11 Vote: I do not like it

I believe that problem F is just a simpler version of JOISC 2019 Designated Cities.

I copied and pasted my AC code and made changes in about 20 minutes (I made some bugs in the segtree during the copy-paste), but I was done 4 minutes after the contest ended :((

The Z function can also solve problem E: 367669514

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

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

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

In problem C, did u forget the test

1
2
1 0 0 2

cuz it has so many early ACs T_T

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

    Yes, I think the adaptive interactor wasn't the best choice, and they probably should have covered the simple case themselves.

    For example, my solution like 367690402 passes when it really should not. Realized it was wrong mid-explanation while streaming T-T.

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

    Agreed, my wrong solution also passed

»
6 weeks ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Solved till D much fast but problem E sucked :)

»
6 weeks ago, hide # |
 
Vote: I like it +43 Vote: I do not like it

For those who have even the slightest idea about AC automaton or KMP, E should be a absolutely trivial problem. I think the other problems are nice but this one placed at the rather crucial position of problem E really isn't a great one, TBH. It wouldn't be quite possible for those without knowledge of this algorithm to solve it and those who know this may be delayed by the earlier problems C-D and missed this E, such that the problem kinda only tests if one knows about KMP......

However, great contest overall~ thanks for such a thrilling game.

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

finally the cheating season has begun I guess : (

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

i came to the same solution to C as the editorial an hour before the contest ended, but gave up 30 minutes later because i wasn't sure whether i could skip (1, 2) or not. what a pity!

»
6 weeks ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

I really suck at construction problems, so I would love to read about more constructions for D that work and how did you come up with them

»
6 weeks ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

I think this editorial got downvoted because many people can't imple D cleanly.

»
6 weeks ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Thought of some weird idea for D during the contest, like "Pick the letter that currently has the highest available amount that does not violate the conditions. If more than one letter is possible to choose, pick the one that is the longest last time used". Then I thought "naaahhh, must be something else" and failed. Turns out my idea was correct somehow 367693038

»
6 weeks ago, hide # |
Rev. 4  
Vote: I like it +5 Vote: I do not like it

I had a solution for E using z-function 367694181

Let $$$dp_i$$$ be the answer for the prefix $$$[0, i)$$$. The solution makes use of the observation that $$$dp_{i + 1} \le dp_i + 1$$$ — if you have a string $$$s$$$ which can be partitioned into $$$k$$$ pieces, then removing the last character of $$$s$$$ gets rid of at most the last prefix, leaving you with $$$k - 1$$$ pieces.

Then you have the transitions $$$dp_j \leftarrow dp_i + 1$$$ for all $$$j \in [i + 1, i + z_i]$$$ (This instantly gives an $$$O(n \log n)$$$ solution using range-update point-query segtree).

Now maintain a set $$$S$$$ of the $$$dp$$$ values as follows.

  1. insert $$$dp_i + 1$$$ into $$$S$$$ at the end of $$$i$$$,
  2. remove $$$dp_i + 1$$$ from $$$S$$$ at the end of $$$i + z_i$$$,
  3. then $$$dp_j = \max(S_j)$$$ where $$$S_j$$$ is the set at the $$$j$$$-th index.

Instead of using an std::multiset to maintain $$$S$$$, just maintain a frequency table with a pointer to its largest non-empty value. In each iteration $$$\max(S)$$$ only increments by $$$1$$$ (due to our initial observation) but may decrease by an arbitrary value, giving us an $$$O(n)$$$ per query solution.

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

    i did same but instead of dp i greedily solve the it after applying z function. int z function we the the length of the largest substr starting at position , so keep the track of the farthest postion you can go in the prefix substr and in between if come and postion which has z value greater then 0 keep it in the vector and subsequently pop accordingly and ans is sum of length at all position ~~~~~ // this is code void sol(){ int n,q;cin>>n>>q; string s;cin>>s; auto zfun=&{ int n = sz(s); vectorz(n,0); z[0]=n; int l =0,r=0; for(int i=1;i<n;i++){ if(i<=r){ z[i]=min(r-i+1,z[i-l]); } while(i+z[i]<n && s[z[i]]==s[z[i]+i]) z[i]++; if(i+z[i]-1>r){ l = i , r = i+z[i]-1; } } return z; }; for(int i=0;i<q;i++) { int l,r;cin>>l>>r; string t = s.substr(l-1,r-l+1); vector z=zfun(t); int ans=0; vectorend; int len= r-l+1; vectortemp(len,0); for(int i=0;i<len;i++){ if(z[i]>0){ end.pb(i+z[i]-1); } while(!end.empty() && end.back()<i)end.pop_back(); ans+=sz(end); temp[i]=sz(end); } cout<<ans<<endl; } } // ~~~~~

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

    Another method is to replace multiset with stack: 367777401

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

      yeah a monotonic stack sort of giving what i consider ranges of influence for each non zero element of the z array. we pick for index i the latest of all possible which can 'influence' it.

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

For D i did something different. I ordered the colors as a,b,c such that a>=b>=c. Then i checked how many (a,b,c) triples (say d is the number of times it's removed) should be removed to eventually satisfy the condition a>=(b+c). The triples can be handled in this manner. We can repeat the triple shifted by 1 each time for d iterations. For example if its rgb and d is 3, the string would be (rgb)(gbr)(brg). We observe that it doesn't violate the given conditions.

Now to handle the left over characters, we know a>=b+c now because we removed the triples. We can pair off each b and c with an a, like (ba)...(ba)(ca)...(ca).

If there are any left over 'a's we can just add one 'a' to the start of the string. So the final string would be of the form (a)(ba)...(ba)(ca)...(ca)(cab)(abc)(bca)....

Depending on whether the first part ends with "a" or "ba" or "ca" we can modify the initial triple so that the given condition is not violated.

My implementation: https://mirror.codeforces.com/contest/2209/submission/367693394

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

    Very cool construction! I also thought about using triplets and shifting them but the idea of handling the rest when c>=a+b didn't come to my mind.

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

my solution for D is as follows:

let's we have $$$r \gt = g \gt = b$$$ we want to maximize size of s in other word we want to minimize no of char we can't place in s so we try to minimize no of wasted $$$r$$$ chars.

if we have $$$r = g \gt = b$$$ then we can always make make $$$s$$$ of size $$$(r + g + b)$$$
now if r > g then we will minimize the difference $$$(r - g)$$$ and the no. of wasted chars will be $$$(r - g)$$$ to minimize $$$(r - g)$$$ we can repeat string $$$brgr$$$ untill we ran out of b.
we can see that for $$$each$$$ $$$b$$$ and $$$g$$$ we are reducing $$$r$$$ by $$$2$$$ so $$$(r - g)$$$ is reduced by $$$1$$$ with each repetation.

unfortunately i couldn't implement the details during round

code
»
6 weeks ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

367699161 I think there is a problem with testcases for the problem C, because this solution wasn't intended to pass all tests, for example if the array stayed unchanged and was 1 0 2 0 it shouldn't work, yet it got an AC.

»
6 weeks ago, hide # |
Rev. 5  
Vote: I like it +12 Vote: I do not like it

Is interactor for C deterministic? Could you provide the source code for the interactor?

I'm asking because solutions like 367653743 (Edit: it got hacked after the comment) pass but they're obviously wrong.

BTW good contest, enjoyed the problems.

  • »
    »
    6 weeks ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    Hi, here is my solution I almost had it during contest made some small mistakes.

    https://mirror.codeforces.com/contest/2209/submission/367703377

    So the approach taht I went for is this, there are exactly n elements and n zeroes in the array. I check every pair from 1,2 all the way to last second pair (excluding). If there was a match I would have received output. Now if there is no match I know for sure that among the last 4 elements I have two zeroes and two numbers. So I apply an algorithm to the last three numbers and in 3 checks I can guarantee if there are two zeroes among these three or not in the following way.

    (i, i+1) -> if(res==1) solved otherwise either i is number or i+1 is number.

    (i+1,i+2) -> if(res==1) solved otherwise either i+1 is number or i+2 is number.

    (i,i+2) -> if(res==1) solved otherwise either i is number or i+2 is number.

    If somehow I get res==0 in all three operations I can successfully concluce that at least two are numbers among last three. If that is the case then it is guarantee that i-1 is definitely a zero since we already knew that last 4 elements consisted of 2 zeroes and two numbers.

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

      Thanks but I didn't ask for the solution. My main issue is that wrong solution passes due to weak interactor.

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

    Naive randomized solution (367712148) WAs but it takes until test 3.

    Maybe their interactor is bugged and/or imperfect. A perfect interactor would probably have to solve the problem "determine if it is possible to put nonzero number at position i, given the previous results of queries". I think this is doable by putting nonzero at position i, and then kind of DFSing if you treat the queries as edges to see if you can end up with a valid config. But then you'd have to make sure the total counts are right, etc etc so it could be a lot more complicated.

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

      Yeah, randomized solutions are not guaranteed to pass and this is understandable. But Why the randomized interactor? or at least the non-deterministic interactor? Wasn't there a way to make the interactor deterministic? I thought it was possible due to the low constraint on $$$n$$$ and really want to see if testers also noticed this & what was there opinion from a problem setting perspective.

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

        I think we're talking about two different things here.

        "randomized solutions are not guaranteed to pass" In this case if the array is fixed from the start, if we assume each query is independent, then we have a 1/4 chance of immediately succeeding when we give a query, so our chance of failure is (3/4)^(n+1) if we make n+1 random queries. At n = 100, that's a $$$10^{-13}$$$ chance of failure.

        So, the interactor must be adaptive (I'm not sure if this is what you mean by deterministic vs nondeterministic) and change the array depending on what queries you ask it / what answer you give. In this case, I think the interactor did an okay but not perfect job of changing the array since a fully randomized solution fails but the one you linked is not that much more complex and got accepted.

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

      As you say, from the queries, we can construct a graph with $$$2n$$$ vertices and $$$n+1$$$ edges between pairs of vertices. Then we assign a nonzero value to the $$$k$$$-th vertex (the program's answer) and remove it from the graph, along with any incident edges.

      Now we have a graph with exactly $$$2n - 1$$$ vertices and at most $$$n + 1$$$ edges left. To give wrong answer the judge must prove that it can label $$$n$$$ vertices zero such that no pair of zeroes is connected by an edge. This is exactly (the decision problem version of) the maximum independent set problem: given this graph, does an independent set of size at least $$$n$$$ exist?

      The independent set problem is NP hard in general, but we can solve it efficiently in this case.

      If any component of size $$$s$$$ has $$$s + 1$$$ or more edges, then that leaves $$$2n - 1 - s$$$ vertices and $$$n + 1 - s - 1$$$ edges for the rest of the graph, which means there are at least $$$(2n - 1 - s) - (n + 1 - s - 1) = n - 1$$$ components in the rest of the graph, and at least $$$n$$$ components in total. But since each component can trivially contain one zero, then the problem is solved.

      If the problem isn't trivially solved, then a component of size $$$s$$$ must have fewer than $$$s + 1$$$ edges, which means either it has $$$s-1$$$ edges, i.e. it's a tree, which is bipartite, and the optimal solution is to set the vertices in the largest part to 0, or it has exactly $$$s$$$ edges, which means it contains a single cycle. Consider two adjacent vertices on the cycle. At least one of them must be nonzero, so we can try to remove each one from the graph, which will create a tree which we can solve as described above.

      If you follow this reasoning a bit further you'll see that the only scenario where we cannot assign at least $$$n$$$ zeros to the graph is when the original graph consists of one complete graph K3, one K1 (which is picked as the answer) and all other components are K2 graphs. That's exactly the graph described in the editorial, of course, but this argument shows that this is the only possible answer.

»
6 weeks ago, hide # |
 
Vote: I like it +10 Vote: I do not like it

My post contest discussion stream for ABCDE
Youtube VOD
Twitch VOD

»
6 weeks ago, hide # |
 
Vote: I like it -39 Vote: I do not like it

pls never make contests again

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

Please someone explain C in a better and more intuitive way, I'm not able to fully understand the editorial.

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

    Think about this:

    1- If you have 4 numbers, at least 2 of them are zeros. Can you determine the position of one of the zeros in 3 or less queries?

    If you answered yes, then you can: pick every 2 consecutive numbers in the array exclusively except any 4, say the first 2 and the last 2. this would cost n-2 queries. Then with the remaining queries, you can use the remaining 3 queries to get the position of any zero in the remaining 4.

    So the array would be something like this (for $$$n = 5$$$):

    1 0 | [2 0 | 3 0 | 4 0] | 5 0

    or

    1 2 | [3 0 | 4 0 | 5 0] | 0 0

    2- Why would the last 4 have at least 2 zeros?

    The interactor is adaptive, meaning it want you to lose by answering 0 as long as it can. If you pick any 2 consecutive numbers to query them, and the interactor responded with zero, this means either there's a zero and a non-zero value, or both are non-zero values. The former means that every 2 consecutive numbers in the array contains one zero, and we queried n-2 of them, this means there're still 2 zeros left. The latter case is trivial.

    • »
      »
      »
      6 weeks ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      Now I understood, when you said the interactor is adaptive and it would want me to lose in the worst case by answering 0 as long as it can, and also the point in the editorial where they mentioned how to make the first query of indices 1 and 2 redundant.

      Now I fully understand the picture and how amazing the problem was. Loved it.

      Thanks for helping me out <3

»
6 weeks ago, hide # |
 
Vote: I like it +9 Vote: I do not like it

Using Z-func for E feels way more natural than KMP lowkey.

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

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

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

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

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

Just wanted to share a slightly simpler and more efficient approach for problem F

To maintain the sum of the top $$$k$$$ elements, instead of using a set, you can use two "erasable heaps". This avoids the heavy constant factor of set operations and runs much faster.

For the rerooting DP part, I completely decoupled the logic into 3 separate DFS passes:

Calculate the optimal paths towards the children from a fake_root.

Calculate the optimal paths towards the parent from a fake_root.

Traverse the tree again to fix the actual root and compute the final answers.

a neat trick: to maintain the condition of "{maximum distance, minimum ID}", you can simply use a pair<int, int> storing {dis, -id} and just take the max()

OwO UwU

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

The tasks were easy to understand, but it was difficult to think about the ideas. I solved 2 problems

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

are all these downvotes coz of c being interactive?

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

can not i plus answer aportly,who can reply

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

well done

»
6 weeks ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

Problem D is a bad problem, and it’s harder than Problem E.

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

Oh god,D rated 1696 on clist is considered hard and E rated 2117 on clist is considered easy.

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

    D seems simple but actually takes a lot of time (E seems difficult, and actually lol), so more people complain about D ,I guess.

  • »
    »
    6 weeks ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    There's always a bias for later problems having higher ratings due to people attempting them in order (A->B->C->D...). But, I think the point most people are making is that D was too hard for a regular D, and E was too easy for a regular E (I don't necessarily agree with one or both statements though).

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

      IMO D should probably be a little higher like 1800 or maybe 1900, I think E is a solid 2100, maybe even slightly harder since you had to find the N Q answer with KMP/Z-func/something like that.

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

Hello Codeforces,

Here is a binary search implementation for D, it is quite messy but I got it to work:

https://mirror.codeforces.com/contest/2209/submission/367805736

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

I am finding it very difficult to understand the problem statement for 2209B - Array. Specifically, "For each index i , find the maximum number of indices j such that j>i and |ai−k|>|aj−k| , over all possible integer values of k .". The provided modulus inequality cannot be satisfied for all possible integer values of k, ~~~~~ ]-Inf,...,-1,0,1,...Inf[ ~~~~~

. Only few Integer values for k can satisfy the inequality. It seems like, for any integer k that satisfies the provided modulus inequality.

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

    It is asking to find the maximum number of indices j, that satisfy the inequality. It is up to you to choose a single number K from all possible integers for each index i.

    I also found it hard to understand at first until I went through the sample cases.

    • »
      »
      »
      6 weeks ago, hide # ^ |
      Rev. 2  
      Vote: I like it 0 Vote: I do not like it

      It was clear about the requirement of the maximum number of indices j for which the inequality is satisfied.

      Additionally, I thought it was also a requirement that the inequality must be satisfied for all Integer as k where the existence of any such k or Integer is enough.

      I could not think in the proper way. I was just confused by the sample case and examples.

      I could get the idea about the real requirement from the provided solution. Thanks.

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

I have a small doubt in B. It says k as all possible integers. Then why do we choose k? Does it say "possible" — to satisfy the condition?

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

can anyone please find what mistake I have made in problem D, this is my solution.

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

Great set of problems!

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

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

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

I did a solve for B. in O(nlogn) using a BIT. Could have been a cool problem if it had harder constraints.

»
5 weeks ago, hide # |
 
Vote: I like it +1 Vote: I do not like it

Started working honestly and not from AI

»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it
  • problem 2209E There seems to be some mistake; why is my solution E duplicated?.It seems there's some kind of misunderstanding, i admit that I referenced and may share ideas with the author Thank you
»
5 weeks ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

for problem d i was thinking it of solving using priority queue, can anybody think of a working, optimal approach using priority queue because the one i implemented gives wrong answer on r=g=b cases

~~~~~ void solve() { int r , g , b;

cin >> r >> g >> b;

priority_queue<pair<int , char> , vector<pair<int , char>>> pq;

if(r > 0) pq.push({r , 'R'});

if(g > 0) pq.push({g , 'G'});

if(b > 0) pq.push({b , 'B'});

string ans = "";

while(!pq.empty()){

    vector<pair<int , char>> store;

    bool placed = false;

    for(int i = 0 ; i < 3 ; i++){

        if(pq.empty()) break;

        auto ele = pq.top();

        pq.pop();

        int temp = ans.size();

        if(temp > 0 && ans[temp-1] == ele.second) {

            store.push_back({ele.first , ele.second});

            continue;
        }

        else if(temp > 2 && ans[temp-3] == ele.second) {

            store.push_back({ele.first , ele.second});

            continue;
        }

        else{

            ans.push_back(ele.second);

            placed = true;

            if(ele.first > 1) store.push_back({ele.first-1 , ele.second});

            break;
        }


    }

    for(auto ele : store){

        pq.push(ele);
    }

    if(!placed) break;


}

cout << ans << endl;

}~~~~~

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

I wonder why greedy algorithm doesn't work in problem E (WA on test 18).

For each query l, r, put l into a stack. For j=l+1..r, if $$$s_j=s_l$$$,put 'j' into the stack, while $$$s_{stack.top..j}$$$ is not prefix of $$$s_{l..j}$$$, pop it. Finally add the number of elements in the stack to the answer.

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

someone please help me find the bugs in this solution for problem D

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

I struggle to understand div2D solution. The code and its idea is clear, but the reasoning in solution is not.

How does "When three continuous ghostfires with different colors, the color of the next one must be equal to the second one." lead to observation "Using the feature, it can be proven that the task is the same as pairing two ghostfires with different colors". I assume in "then it's valid to add just a single ball", the ball in this context is a ghostfire, right? "remember to choose the pairs with the same color ghostfires as the first ghostfire to avoid getting wrong on case r=g=b=2" — what is it about, could you explain?

»
9 days ago, hide # |
Rev. 4  
Vote: I like it 0 Vote: I do not like it

Problem A says he fights monsters in order and solutions seems he can fightin any order

..... for me its battle of english

Even in problem b i didnt even understood the question lol its says for all k what does it even mean for all possible k