mohammedehab2002's blog

By mohammedehab2002, 3 months ago, In English

Hi everyone!

Codeforces round #649 will take place on 13.06.2020 18:05 (Московское время). It's rated for the second division, but, as usual, first division participants can take part out of competition.

The problems were created by me. I'd like to thank my forever orzable coordinator antontrygubO_o; my incredible army of testers dorijanlendvaj, 300iq, Osama_Alkhodairy, AmShZ, Taran_1407, TigranMec, _Aaryan_, Mohammad_Yasser, zoooma13, lavish315, Utkarsh.25dec, NOOBxCODER, and Laggy; and, of course, you-know-who for the amazing codeforces and polygon platforms.

This time, in an effort to kill type-races and because I'm lazy, you'll be given 5 problems and 2 hours to solve them.

UPD: the scoring distribution will be 750-1000-1500-2000-2500.

UPD: the editorial is out.

UPD: congratulations to the winners!

Div.1:-

  1. Um_nik
  2. kefaa2
  3. hank55663
  4. noimi
  5. neal

Div.2:-

  1. SanyaSaske
  2. Chloristendika
  3. el_risitas
  4. Sr.Phoulady
  5. tzxydby

Good luck & Have fun :D

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

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

mohammedehab2002 and his xor.

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

Incoming XOR missiles...

»
3 months ago, # |
  Vote: I like it -154 Vote: I do not like it

The problems were created by me The problems are*??

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

*Codeforces Round #649 (Div. 2), writers: mohammedehab2002*

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

You-know-who

Making Mike sound like Lord Voldemort

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

Oh.. Thank you for thanking me for the amazing Codeforces and polygon platforms, almost forgot :P

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

mohammedehab2002 and his short statements.

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

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

Wait so what is up with the xor stuff? Sorry if I'm a noob and I don't know the jokes.

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

A contest that has short statements is rarely found, so I advice you to register this contest :))

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

you-know-who for the amazing codeforces

Seems like there might be some XOR stuff along with Harry Potter

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

Did you mean YouKn0wWho!

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

kill type-races and because I'm lazy, so contest is going to be a bit hard and tricky . I am excited for it .

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

    I don't think this killed too many type-races. ;)

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

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

    Next problem names could be like=>

    A. Ehab and XOR problem(1) B. Ehab and XOR problem(2) C. Ehab and XOR problem(3) D. Ehab and XOR problem(4) E. Ehab and XOR problem(5)

    :D:D:D

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

    This time I hope to see the problem "Ehab goes to Rehab" xD xD

»
3 months ago, # |
Rev. 7   Vote: I like it -52 Vote: I do not like it

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

This is how my division 2 round with just 5 problems is like....

PROBLEM A

WRONG ANSWER TEST CASE 2
TIME LIMIT EXCEEDED TEST CASE 2
WRONG ANSWER TEST CASE 2
WRONG ANSWER TEST CASE 2
WRONG ANSWER TEST CASE 2
TIME LIMIT EXCEEDED TEST CASE 2......

and finally brain shutdowns...

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

    SO MANY DOWNVOTES!!!! But unfortunately I ended ,the more or less same way......

»
3 months ago, # |
Rev. 6   Vote: I like it -72 Vote: I do not like it

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

Hope there is not unexpectedly high increase in difficulty from B to C :)

»
3 months ago, # |
  Vote: I like it -42 Vote: I do not like it

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

If someone can give link for 5 problem div 2 contests it would be a great help

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

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

mohammedehab2002 the XORcist

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

Probable difficulty of problems-

A-1200- math

B-1400- greedy or number theory

C-1700- constructive algorithms and trees

D-1900/2000 — XOR, constructive algorithms

E-2100+ — Beyond my guess :P

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

4 testers from IIT Kanpur :O

Probably maximum this time

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

After antontrygubO_o's comment on Ashishgup's blog.
*Le mohammedehab2002 : My forever orzable coordinator antontrygubO_o :)

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

.

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

Is this rated for participants with ratings up to 2100, or only up to 1900? It seems to vary for Division 2 rounds.

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

    2100

    Div. 2 only rounds are rated for participants <2100 while in parallel Div 1 and 2 rounds, the Div.2 round is rated for participants <1900.

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

      What is the explanation for such kind of division?

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

        Well, most of people with rating 1900-2100 should be able to solve up to Div2 D (included) or even Div2 E for upper rating participants (like 2000-2100), so argument for puting them in Div.1 is: they don't need to solve first two or so problems, and can focus more on Div2 E and harder problems. They would on average lose maybe 15-20 minutes on average Div2 A+B, but that is the time that can make difference between not solving Div2 E (= Div1 C) and solving it.

        I think that argument for allowing them to participate on average Div2 is to make them do more practice: Div1 is really rare!

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

May be the shortest announcement of a div.2 ever

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

    Because, he thanked everyone in a single paragraph instead of making a list like most other authors.

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

Why people focusing a lot on XOR. Can someone explain me in detail. so may be it will helpful not only for me but for others too may be in tomorow contest.

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

    Look at his before contest..most of the time he presents some problem with XOR .

»
3 months ago, # |
  Vote: I like it -6 Vote: I do not like it

I hope the problem statements will be as short as the announcement.

»
3 months ago, # |
  Vote: I like it -36 Vote: I do not like it

13 testers for just 5 problems, Isn't it strange ?

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

Edited-I posted on a different contest, I was asking for educational round.....Sorry!!

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

I think this time mohammedehab2002 will give us surprise and there won't be any xor related problem :P

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

Looking forward to this round, man!

You know the deal, upsolving the problems 5 mins after the round ends: https://youtu.be/2jW2zTSoGCM

Good luck and have fun!

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

    Your videos are the best ! Keep up the good work.

»
3 months ago, # |
  Vote: I like it -45 Vote: I do not like it

Hope Ehab saves us from the steep rating drop caused by AshishGup !!! HaHa...

I know you're going to downvote the comment, Go ahead !!! XD !!!

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

As a tester, I can confirm that the number of letters in problem B's statement is a 4-digit number and that the number of occurrences of the letter 'e' is a 3-digit number.

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

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

5 problems ..

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

    From the diagram given above you are surely gonna fall..... As you took a jump bit early...

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

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

I hope Problem names Will be greater than Problem statements as usual

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

The first problem's score is $$$750$$$, So hard contest?

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

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

I guess Contest will be unrated if no xor problems will be given :)

»
3 months ago, # |
  Vote: I like it -30 Vote: I do not like it

mohammedehab2002 be like :

meme

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

Seems like today I can just solve upto B

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

preparing myself to become pupil [EDIT: Why everyone downvoting me, it actually happened)

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

First time seeing an announcement without explicitly naming Mike hah

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

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

mohammedehab2002 I think you should mention the unusual start time. I have opened the blog almost 3-4 times since yesterday but noticed the start time just now when told by a friend.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it -27 Vote: I do not like it

    It is starting at the same time as LeetCode BiWeekly :(

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

Unusual time contests are disaster. ps: Mat maan maa chuda

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

mohammedehab2002 I never try his competition but when I saw comments, it seems like he will give questions in which xor will be used.

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

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

mohammedehab2002 unfortunately, we can't participate in the leetcode and codeforces contests at the same time. the thing I want to say is most people will choose codeforces because it's lot big platform than leetcode. but newbies like me can gain high points by attending both the biweekly and weekly challanges of the same week. it could have been earlier or after the other contest.

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

A significantly low number of registrations compared to previous rounds. Probably because of the score distribution. Or maybe because of the start time.

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

Good luck to everyone!

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

Problem D is almost exactly the same as 1325F - Ehab's Last Theorem ?Isn't it ?

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

    Agreed

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

    recycled

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

    I think they must be different.

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

    You probably should have commented this after the contest ended, not when it was going on.

    But yeah, knowing that problem exists (even if you haven't solved it) is a massive help even though the condition here is much easier than it that case. If you can figure out the property using the size of the smallest circle, it can be solved in a similar manner to that problem.

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

      Yes, it is true. I was not thoughtful sorry!

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

      Not only a massive help, it kills the problem. I copied my solution to that F and changed like 4 lines.

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

    and they have the same author?? but why?

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

    that why i could not solve it.

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

    Yes it is.

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

.

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

Thanks! I enjoy doing it today

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

How did you solve C?

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

    Constructive algorithm , Find a set of elements which are not present in the given array, sort these set of elements , Now Answer exists only when given array is sorted and there exist no such position i in array such that a[i]>i.

    After doing these things lets say ans is our ans array Move on in the array till a[i]==a[i-1] and pop out elements from the given set
    and push in answer array

    and when you reach a[i]!=a[i-1] push a[i-1] into the answer array and repeat this till you reach the end of the array.

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

    For problem C I feel it was difficult to come up with such construction

    I did not observe that for $$$ a_i {!=} a_{i-1}$$$ ans is b[i] = a[i-1]

    What I did :

    1. A maintained list of numbers that are exactly between any two different $$$ a_i $$$'s. So that I can pick one by one element from list wherever I need them.
    2. Maintained missing number or mex, after inserting $$$ b_{i-1} $$$.
    3. If my missing number is less than $$$ a_i $$$ then fill b[i] = missing_number and check next missing number is a[i] or not, cause now updated missing_num should be a[i] for it to be mex.
    4. If my missing_number = a[i] then that's it, we have already done our job now you can use this chance you take elements greater than $$$ a_i $$$ i.e we have maintained the separate list for this purpose (step 1)

    My submission :83684656

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

I cannot implement D but is this approach fine:

Find any minimal cycle in $$$G$$$. If its length is $$$\le k$$$ then we are done. If its length is greater than $$$k$$$ and say it is $$$L$$$ then we can split this minimal cycle into 2 set of $$$\lfloor\frac{L}{2}\rfloor$$$ vertices such that the set are bipartite. Then choose $$$\lceil\frac{k}{2}\rceil$$$.

This may be wrong but I was not able to find minimal cycle (cannot implement)

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

    I thought of the same thing, but couldn't think of a way to find the minimal cycle in O(n)

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

      There is actually no known way to find the smallest cycle in O(n). The idea is that you can start looking for a cycle, and if you move k-1 away without finding one, then at that point you can just put independent vertices alternating on the length k path you found.

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

        thank you i was a bit confused with the solutions.

  • »
    »
    3 months ago, # ^ |
    Rev. 3   Vote: I like it +9 Vote: I do not like it

    Yup, thats the basic idea.

    There is also the case of there being no cycle, but then its just the task of forming a bipartite set out of the tree which is trivial.

    As for how to implement it, take a look at DFS Tree, I think it should be pretty intuitive after that.

    Idea if you are still stuck

    OR just read his editorial for a problem of a similar premise (problem F)

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

    I solved D after the contest, I used same approach, additionally if we can not find a cycle in the graph, then the graph is a bipartite, then we can simply choose and print the set with atleast ⌈k/2⌉ nodes. 83694575

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

How to solve E?

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

    you soved a,b,c,d with only one submisiion, I feel really sad that you could not solve e

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

      He is master in doing these things :p

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

How to solve E? I managed to get AC by using random + some optimizations

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

    How?

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

      First of all you should find 0. Keep a candidate array where 0 could be. Then go through this array multiple times until 1 candidate remains. For each candidate pick 2 elements B and C randomly. Let's denote this candidate value by A. Then check if (A | B) & (B | C) = (A | B), if not then A is not a valid candidate. To get less than 4269 queries use some previous queries and also don't query the same pair of elements twice.

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

        I had the same idea but did not searched randomly and could not fit into the limit.

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

    Couldn't get AC, I tried to find an element by applying 170 random queries and use this element to find the 0 element. Can anyone please help me find out why this was wrong.

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

      I thought if I apply a alot of queries to one number, there would be at least one number with bit 0 for every bit positions.

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

Did somebody please Help why I am getting WA on test 2 of problem A , I used Binary Search and Segment tree 83678283

Edit : Wrong Logic

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

How to solve D?

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

What is test 25 in problem D?

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

    I think it is a tree with an independent set of size > K/2.

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

      Thanks, that was my issue!

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

      Just curious, how did you arrive at that conclusion?

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

        I also failed on this testcase and had the same error.

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

Swap (A, B)

O.o

»
3 months ago, # |
Rev. 4   Vote: I like it -11 Vote: I do not like it

In Problem C, earlier I wrote a code which might generate equal elements in array b but kept getting WA on test 4. After that the only change I made was make the elements distint and it passed the pretests. Any idea why ? Link to submissions : 83672136 83682310

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

    They don't have to be unique. My code which may generate duplicate values passed pretests

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

      And the problem is still solvable even if the elements have to be unique. For any value of b that is duplicated previously, just set it to a value that hasn't been used before which is greater than $$$10^5$$$.

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

    Elements of b not necessarily unique. For example sample 2.

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

    Elements in b need not be unique. I had the same doubt and asked the question and they said it can repeat

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

Am I the only one who doesn't know how to read and ignored the fact that Subarray was written & explained on problem A?

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

    No I am with you :P

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

      LOL, I figured it out 4 min to the end, coded it wrong, and got accepted at 1:59:59 SMH

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

        Happens sometimes. How did you solve C?

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

          To solve C i used an Set. For each integer from 0 to mx, where mx is the maximum value of the array, I include them into the set. Then, for some extra values, like n+2, I added them too. So, let ans be the array representing the answer and vet the given array. If vet[i]!=vet[i-1], I said that ans[i] = vet[i-1]. Then, I erase vet[i-1] from the set. Then, all the other ans are -1, which means we dont know it yet. If we loop from all the positions, if ans == -1, we add the first not used element from the set, thus, giving us a valid answer!

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

    I tried to use kadane's algorithm with a tweak but didn't work. Any corner case? Or is it that first we need to calculate the whole sum and simulate what the problem definition demands i.e. taking out elements from left and right?

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

    Me too lol

»
3 months ago, # |
  Vote: I like it -63 Vote: I do not like it

Worst Contest Ever

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

Was that the most difficult div2 A problem, ever? or did I miss something?

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

    Cannot agree more to you!

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

      What's worse is my wrong solution passes A. Whole contest I kept trying to fix it cause I knew it was wrong. And it passed ST wtf. It will fail for this. 1 5 2 2 3 1 2 1

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

      thats true

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

Is there any case for problem C for which output is -1? I don't find any case like that.

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

Jesus christ it took me 1 hour 54 minutes to solve A but <1 hour to get B and C :\

I'm about to get screwed by delta change

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

    Can you explain how to solve A.

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

      Basically if sum of all elements is non-zero mod x, return n.

      If all the elements are 0 mod x, return -1.

      Otherwise, return max(n-f-1, l-1), where f is the index of the first non-zero element, and l is the index of the last non-zero element.

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

Interesting problems, as usual (excellent/brief descriptions!), but that was a tough problem A...

It feels like Div 2 contests are getting a lot harder in general.

This comment/meme was so accurate

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

    "Div2 Contests are getting a lot harder in general" ?

    WTF? These days I feel they are a lot easier than before. Problem E in last 5-6 contests was easy (Except this one ofc).

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it -10 Vote: I do not like it

      Well, perspective I suppose. I've been taking a beating so it definitely feels tough to me. Did you find today's problems easier than usual?

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

        Nope. I literally wrote "except this one in parenthesis". Today's E was nice.

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

      easy $$$\neq$$$ easier

      Also, of course E is going to be easier the more problems there are and recently div2s have more problems than before.

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

        Yeah ik. I am talking about normal 6 problem rounds. I feel Es are easier than they used to be. 5 problem rounds' E is obviously much tougher to 6 problem rounds in general

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

          I'm not really sure about that, it might be related to the fact that you are better now than when you were solving old Es.

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

    I guess I've been downvoted quite a bit for these couple of comments. Not entirely sure why, since I was just sharing an opinion, but thought I'd provide some background to anyone who cares to read :

    • The percentage of people who submitted any problems (relative to the total registered users) in the last contest seemed to be a lot smaller than the past few contests.
    • Problem A was a lot harder than it usually is (the number of submissions, even after 20-25 minutes, was low). I am generally able to get A in quickly, so having 1 failed solution and then taking another 20 minutes was a major downer. Obviously, in retrospect, things look a little easier.
    • Towards the end of the contest, CF Predictor showed a net loss of -36 points in my rating, so it was frustrating to see that even after getting 3 problems in during a Div 2 round with 5 problems (though at the time I wasn't sure that they would all pass). Eventually, my rating went up slightly, so that prediction turned out to be incorrect.

    Anyway, perhaps a nice feature to have on Codeforces would be a poll option. This way, we could get near real-time feedback from the community.

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

Even til the end of the contest didn't I konw why my binary search for A WA on test 2....

DIV3 I'm coming :)

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

    same with me I tried segtree and BS but kept getting WA over 4 times is some problem with the approach ??

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it -6 Vote: I do not like it

      I'm waiting for the case 2 open...

      It's 1 am now in China... I want to figure it out why BS wa on test 2 before go to sleep.

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

        5 3 1 1 1 1 1 Simulate your binary search on this testcase.

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

        If you look carefully at Test 2, last input: 8 2 0 1 0 1 0 1 0 1 binary search will start searching for a good subarray of length 8 then 4 then 2, all of which do not exist. After that it will search for 3, which will be the maximum length according to BS. So it will return 3.

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

      You tried segtree and bs to solve a div2A? :|

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

        I had done some similar problems recently involving similar ideas and after misinterpreting what "subarray" meant I thought that was the best way to go !!! XD Moreover I just had to edit the code slightly to adjust the problem rather than creating one from scratch

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

    In the case of Binary Search, when you don't find a solution for a particular size, you reduce the size(range). There may be the case that there exists a size of the subarray that is greater than current size you checked. Hence wrong logic.

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

      Now I got it...

      Just for the first sight thought it must be a BS problem, when I konw why it isn't, so happy with me. The whole 2 hours of confusion is now gone away.

      Though ratings down, get knowledge :) , seems we need to check it out if it can use BS then only one side of mid is acceptable. In A, if we choose mid==2 then mid==1 and mid==3 are both acceptable but BS only go one way so it is wrong.

      Never consider it before...

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

        Well I never knew what the definition of "subarray" meant for this contest until the contest ended :(

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

    I thought to use bs too. Luckily passed all tests: 83624037

    Hack test:

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

      LOL, lucky you. My BS just got wa 2. Seems the way we write BS is different.

»
3 months ago, # |
  Vote: I like it -61 Vote: I do not like it

I want a quick editorIAL NOW !!!!!!.

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

https://codeforces.com/contest/1325/problem/F

The Problem D today was VERY SIMILAR to this problem. It gives many participants unfair advantage. Please look into this. mohammedehab2002

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

    The solution to today's question can be obtained by a simple modification to the code given in the editorial of this problem.

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

      Yes I agree. This problem gives an unfair advantage to those who have not read that problem.

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

      I also tried to remember that this type of similar problem I had seen before somewhere else :|. Anyway, I enjoyed the problem. My favourite one of today's problem set <3 .

  • »
    »
    3 months ago, # ^ |
      Vote: I like it -11 Vote: I do not like it

    Well, the idea is pretty standard anyway

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

      Yes, I agree in principle that the idea is standard and every question will use ideas which are known to people. But I also believe that there should be some threshold of originality in the questions so that it does not give people who have seen the questions previously to simply copy the code and make slight modifications to achieve the solution. It gives them unfair advantage by saving them a lot of implementation time.

      Also I don't think it was a very straightforward problem for people in my rating range as only 346 people could solve it. :(

      Other than that, the questions were really good and I enjoyed solving them :)

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

        Agree, the most uncomfortable is that it was the same problemsetter.

        because I'm lazy, you'll be given 5 problems

        This does not look like a joke anymore!

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

        i agree with your reason. when i come to E problem, i think that this problem is like already solved problem.. And After i read your comments, i realized my thought is correct

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

Problem A was tricky (for some) when it comes to the definition of subarray. I overlooked it and it took me 3 WAs to find out what was wrong...

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

    yep and it took me 1 WA, not paying attention to the word "subarray" and solving it for "subsequence".

  • »
    »
    3 months ago, # ^ |
    Rev. 3   Vote: I like it +1 Vote: I do not like it

    Can you Please tell if I misinterpreted the definition of the subarray here , otherwise my soln seems fine 83678283

    Edit : I did :(

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

      If there is an array $$$A$$$ with elements $$$a_1, a_2, ..., a_n$$$, then a subarray of $$$A$$$ is an array with only all the elements between $$$l$$$ and $$$r$$$, where $$$1<=l<=r<=n$$$, i.e. it has elements $$$a_l,a_{l+1},...,a_r$$$.

      On a side note, binary search + segment tree for div2 A is totally unnecessary...

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

      Why you are using binary search in segment tree? I think you will miss many cases with this. From your solution,i can infer that the length of subarray is independent of values of array, whereas it is dependent. My solution -

      Spoiler

      Sorry for my bad English.

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

      The case that your solution failed one was ~~~~~ 1 4 7 ~~~~~

      So you definition of subarray is not what caused your code to give WA. Based on your code, I think your definition is correct.

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

    True, lesson learned — read twice code once. it was tough to see what the question meant once i was sure answer would be n or n-1 or -1.

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

mohammedehab2002 and Testers after the contest.

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

    When I could'nt solve A even after 15 min had passed..

    Me thinking : "Is subarray size related to Xor of elements?" :facepalm:

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

What a terrible contest: why the hell is the gradient so high between C and D? It should have been at-most 2000 rated but this D is sure to be >=2200.

And to top it off, D was knowledge-based (DFS Tree) and implementation heavy. Such an underwhelming speedforces contest :|

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

Erm weaktestcases for D? I just commented my assert and it got AC. Please uphack this.

Solution

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

Why the weak pretests? :((((

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

-1 is not possible for Problem C There have no any case in the testing input. How funny!!!!!

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

    He is right..Then i don't understand why people down-voting. Cause,, A is sorted and Ai <= i, the answer will always exist.

»
3 months ago, # |
  Vote: I like it -28 Vote: I do not like it

Weak Test Cases of Problem C

Following solution fails for very basic test case 2 0 2 (Why No test case exists for -1 answer in main test cases )`` 83678632 1364C - Ehab and Prefix MEXs Solution

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

    Read the constraints properly. It says Ai<=i

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

    If you mean

    2

    0 2

    Then output is 1 0

    And if you mean

    3

    2 0 2

    Then input is not valid. Since a[i] sorted in nondecreasing order and 0<=a[i]<=i. With this constraint there exist no such case for which output is -1 so that you can't find such case in testcases.

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

For question D, Could anyone please tell me, what am i missing ? 83685667

  • »
    »
    3 months ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    I think you should add depth[x] — depth[y] + 1 >= 3 in your dfs

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

      Sorry, But I retried its not the case. I guess it has issues when there is no cycle.

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

    Try this test: 3 2 3 1 2 1 3

    The answer should be: 1 2 3 But your code gives the output: 1 1

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

      Thank you so much, I get it

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

        What was the problem? Something wrong with coloring?

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

          In case of a star graph, I considered only one case, so I was failing.

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

            you mean, when you colored vertexes, you considered only black(white) ones?

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

For D I did this: First, considered the case separately if the given graph was a tree, by building the bipartite graph. Otherwise, find any cycle in the graph and recursively check while the length of the cycle is greater than k, check for any edge within the cycle breaking the cycle into two and solving again for these two cycles. And if there's no edge within a cycle and size is greater than k, print the independent set.

I guess this should give TLE for some test, could anyone try to uphack it? 83682515

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

Hi, I am a newbie in this platform, I am a little bit good with converting logic into code but i can't even understand the logic behind the problem A. I think I should need to learn a lot of things. can anyone suggests tops I should need to cover? to solve all problems. Some best resources or video lectures would be helpful.

Thanks in advance!!!!!!!!!

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

    Do a lot of practice starting from the level just above you. Go to problem-set and sort it in decreasing number of submissions and start solving. Don't invest more than 20 mins on a question. Later do check out its editorial to find out the algorithms which you are missing in your knowledge bank.

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

In Problem D,
-> First I checked if problem 2 can be solved. If it can be then print the result -> Otherwise, for 1st problem, if I run a DFS from 1 and construct two set where 1st set contains vertices that has nodes that has even depth and 2nd set contains nodes that has odd depth. Then, isn't it possible to choose ceil(k/2) independent vertices from either set 1 or set 2. I got WA on testcase 49. My intuition was, those chosen ceil(k/2) would form an independent set. If they are not then, there will be a cycle which has length <= k.

Can anyone help me understand why I got WA.

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

For everyone saying this D and last F are the too similar. Well, it can't be true that both me and antontrygubO_o have been drunk since my last round to not notice if they aren't different enough. Yes, they have very similar statements, but they have very different solutions, which is obviously the case since one of them are about SHORT cycles and the other is about LONG ones. I mean, are "find the shortest cycle" and "find the longest cycle" similar problems? One is simple $$$O(n^2)$$$ bfs and one is NP-hard.

Please, read the solutions for both problems before you judge.

Today's D:

The common idea is: if the graph is a tree, you can easily find an independent set with size $$$\lceil\frac{n}{2}\rceil$$$ by bicoloring the vertices and taking the vertices from the more frequent color. Otherwise, the graph is cyclic. Let's get a cycle that doesn't have any edges "cutting through it." In other words, it doesn't have any pair of non-adjacent vertices connected by an edge. If its length is at most $$$k$$$, print it. Otherwise, take every other vertex (take a vertex and leave a vertex) and you'll end up with a big enough independent set. How to find such cycle?

Let's do a dfs in our graph. In the very first time we hit a node that has a back-edge, we take the back-edge that goes to the deepest possible node to close our cycle. This cycle can't have any edges crossing it because none of our node's ancestors has a back-edge (by definition.)

Last round's F:

Let $$$sq$$$ denote $$$\lceil\sqrt{n}\rceil$$$.

Let's take the DFS tree of our graph. Assume you're currently in node $$$u$$$ in the DFS. If $$$u$$$ has $$$sq-1$$$ or more back-edges, look at the one that connects $$$u$$$ to its furthest ancestor. It forms a cycle of length at least $$$sq$$$. If $$$u$$$ doesn't have that many back-edges, you can add it to the independent set (if none of its neighbors was added.) That way, if you don't find a cycle, every node only blocks at most $$$sq-1$$$ other nodes, the ones connected to it by a back-edge, so you'll find an independent set!

For people saying they copied the solution and changed something and got AC, I'm assuming you have a reasoning for why your solutions work. If you can give a proof (longest cycle)*(maximum independent set)>=(number of vertices), and use the same or similar proof to prove 2*(maximum independent set)>=(shortest cycle) please give me that proof because I'm interested to hear it.

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

    Ok so compare this and this. I just made changes at few places. And yeah, still analyzing the old submission.

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

    we still love your questions.

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

    I have just copied the code from last editorial of F and changed just: -> sq to k -> >= to <= and it got accepted. why you not also copied the other question. This was the wrost round I ever given.

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

    This code and this code are exactly same, I just changed less than equal to greater than equal. And got AC in both.

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

    Even the statements were so similar in both the problems, the least you could have done is change the statements so that on googling it would have not linked to the older problem. How lazy and overconfident does one have to be to not do this

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

Could somebody point out the mistake in this logic for D : Go to every back-edge (u,v) and find the distance b/w u and v in the dfs tree, if the distance is < k then we just found a cycle. If no back-edge satisfies this condition then select the independent set by dividing the graph into bipartite sets.

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

Can someone look at this(Problem C) 83665936. Got Wrong at TC25

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

    As elements of array b must be less than or equal to 1000000 as said in constriants.

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

MikeMirzayanov my rating got increased even though I should be out of competition.

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

    You probably registered for this contest while you were a Candidate Master.

»
3 months ago, # |
  Vote: I like it -9 Vote: I do not like it
»
3 months ago, # |
  Vote: I like it -8 Vote: I do not like it

I couldn't find anything about xor in the first 2 question.

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

Hey, I have given the correct solution for the first question, but it shows an error on test 2 and when I resubmit the same code. It accepts the solution.

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

    The system does not accept resubmitting unchanged code.

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

      See submission 83638170 and 83694208. Both has exact same code.

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

        You code is buggy, vector "dp" should have size x and not n. Both solutions are buggy and same. Both should have received RTE ideally. But, c++ is not very strict about index out of bound and hence your solution is passing probably.

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

MikeMirzayanov

suta was first division participants before this contest, but his rating is changed.

bug?

»
3 months ago, # |
  Vote: I like it -34 Vote: I do not like it

Why weak pretests in Problem C? System Testing did not cover the case where the solution is -1. :(

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

    There is no solution with the given constraints where the answer can be -1. Since A is sorted and Ai <= i, the answer will always exist.

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

    Do you have any testcase under given constraint for which output is -1? If you have any, let us know. Everyone along with author will be happy to see that.

»
3 months ago, # |
  Vote: I like it -24 Vote: I do not like it

https://codeforces.com/contest/1325/problem/F

The Problem D today was VERY SIMILAR to this problem. It gives many participants unfair advantage.

  • »
    »
    3 months ago, # ^ |
      Vote: I like it -29 Vote: I do not like it
  • »
    »
    3 months ago, # ^ |
      Vote: I like it +19 Vote: I do not like it

    Though I didn't solve it, but you can say similar thing for almost every problem. Just bring any red coder and he will point out a similar problem to every problem of this round.

»
3 months ago, # |
  Vote: I like it -32 Vote: I do not like it

Upvote this to get AC in 4 questions only in your next contest. T_T

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

I want to share one thing about problem 1364D - Ehab's Last Corollary, Today I submitted code and my code 83718270 was accepted. But Later I found that it is giving me wrong answer for below testcase.

Testcase:
Output:
»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

problem B wasn't python friendly.

»
3 months ago, # |
  Vote: I like it -24 Vote: I do not like it

verry bad!