yunetive29's blog

By yunetive29, history, 15 months ago, translation, In English

Thank you for participating! We hope you enjoyed our problems

Author and developer is yunetive29

2059A - Milya and Two Arrays

Solution
Implementation

2059B - Cost of the Array

Author and developer is yunetive29

Solution
Implementation

2059C - Customer Service

Author and developer is yunetive29

Solution
Implementation

2059D - Graph and Graph

Author and developer is yunetive29

Solution
Implementation

2059E1 - Stop Gaming (Easy Version)

Author shfs and developer is yunetive29

Hint 1
Hint 2
Hint 3
Solution
Implementation

2059E2 - Stop Gaming (Hard Version)

Author shfs and developer is yunetive29

Solution
Implementation
  • Vote: I like it
  • +77
  • Vote: I do not like it

| Write comment?
»
15 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

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

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

Wait your released the editorial with code 30 minutes before round ended? That's absurd!?

EDIT: My apologies. I had a gap in my knowledge.

»
15 months ago, hide # |
 
Vote: I like it -9 Vote: I do not like it

Skill Issue. I only solved AD lmao

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

    creative issue? Codeforces usually have some creative problem.

    First time i joined Codeforces also struggled with these "creative problem"s

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

      If you mean that I'm creative to solve AD then no because D is standard asf

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

        I mean B,C require some creativity or just familiarity with codeforces problem.

        Yeah D is standard, just scary at first read.

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

        Hey can you tell me how is it standard?

        Are there any similar problems or blogs on this approach?

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

          Cause it uses djikstra algorithm as the main solution.

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

            Just because a solution uses an algorithm doesn't mean the problem is standard. With that said problem D is pretty standard.

            • »
              »
              »
              »
              »
              »
              »
              15 months ago, hide # ^ |
               
              Vote: I like it 0 Vote: I do not like it
              1. My argument would be djikstra appear frequently in many contests.

              2. I'll also add the solution only differs a little bit from a well known algorithm. bonus points if it doesn't require modification.

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

          I am not sure but I mean it's just a no brainer I guess I can't use the right words

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

            I guess I got it, it's easy.

            the Djikstra with a 2D state was just a bit confusing to visualize to me.

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

      Any suggestions on how to solve or atleast approach those creative problems?

      • »
        »
        »
        »
        15 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it
        1. Try solving easier cases first, usually starts with n=1 after you're comfortable then generalize the solution. If you check my submission you can see how i worked from easier case, though it's not a beautiful submission. 304090629

        2. Try learning some quirks of certain problem, like "n is even", bitwise XOR/AND/OR, MEX. They usually share some similarity in approach.

        3. Practice alot of codeforces problem, if you plan to stay.

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

          Thanks for your suggestions. I cannot understand your quirks point. Do you mean to say that if "n is even", then we can use bitwise XOR/AND/OR, MEX somehow or anything else?

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

            no, many of the creative problem usually have some constraint that may contain hint to solving it.

            if n is even:

            usually i try to divide the array into 2 parts

            or maybe in different question, divide the array into n/2 2-sized sub-array

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

    Spend 1 hours to find a case of ans 3 in B :(

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

    how did you manage to go from 2100 to 1600! concerning.. any advice?

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

I personally felt problem B and C were nice! (even though problem B ruined my contest lol) Simple ideas, yet tricky!

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

304115975,304141983,304098763 Can someone hack them

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

I am quite shocked how my B passed the system tests. I was checking for min max in a range but forgot to sort the vector d. I realised this mid contest and was pretty sure it would fail the system tests because I myself can think of countless test cases to hack it. Or is it because of some mathematical property I am missing? Could someone explain?

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

Is it just me or B is unexpectedly hard today?

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

    I found it very tricky to find an error in my solution. The problem isn't hard, but you need to carefully check your output.

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

    Me too.QAQ. I take much more time than solving D to solve B QAQ.It's really tricky for me.

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

good contest , bad contest

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

    Why do people think it was a bad contest? Because D was GPT-able? That is not the problemsetters' fault...

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

      Why do you think it was a good contest? because you performed well?

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

        I didn't perform well. A was acceptable, B was also acceptable, C was good, and D was a bit standard but I enjoyed arriving at the conclusion. E1 was solved by a hundred people and E2 was unsolvable for Div. 2. What exactly is bad about this round?

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

          Because both E1 and E2 are too difficult, D is *1847,E1 is *2565, and the difficulty span is too large. In a good div2, E is *2100, F is *2500 is more appropriate.

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

            I tested this round a while ago and I am surprised that they went with the current score distribution. I told them that B was hard, D was super easy and E1 was too hard, and the number of solves exactly shows that too. I'm not sure if other testers thought the other way, but $$$2000 - 1500$$$ for D and E1 is quite unreasonable, even though for some reason people usually don't like to give enough score to a subtask.

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

      I think it's because b is harder than c to many people.

      And also too few question? (makes my hand sweaty)

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

my E1 Solution is much simpler than Tutorial : 304156702

just track the numbers you must push in next array by using queue

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

For B, I spent 1hour to find a case of which the ans is 3 to hack my wa submisson then I reallized it's impossible :( (I have no enough time to finish C)

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

Just found out my mistake in E1 :(

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

I wanna become an expert. I have come close quite a few times but missed the mark by inches. Please suggest some resources so that I'll be able to do Codeforces Div 2 Problem D in upcoming contests.

Thanks in advance!!

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

    Solve a lot of 1700-2000 problems, it's the only way. Use the filter in codeforces.

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

      Became an expert today. Thanks Drakkon Any suggestions to become CM.

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

        Congratulations Bro !! What you need now is consistency in solving a,b,c fast and also solve d if it's not too hard. To do that you will need to solve alot of 1700-2000 problems + virtual contests in order to be faster.

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

When I saw D and thought about Dijkstra with $$$V = E = 1000000$$$, I thought about doing some kind of "BFS0/1" instead. Then I guessed the distance couldn't be greater than $$$n\times n$$$ (guessed any reachable vertex can be reached in less than n steps, now I think it's actually 2n steps.) and did a BFS with $$$(n+1)\times (n+1) + 1$$$ queues. Hack here if it's wrong -> 304106582

Anyway, $$$O(n\ log\ n)$$$ for $$$n = 1000000$$$ and TL = 2s is the new standard?

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

A much simpler implementation of E1 304178286

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

can anyone explain the last sample testcase of E1.

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

can someone explain how the answer can be 3 for this test (for c problem):
4
4 2 2 17
1 9 3 1
5 5 5 11
1 2 1 1

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

    3 -> 4 -> 2 -> 1

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

    I had the same question and thought about it for over 30 minutes, but the conclusion was absurd. Each hour is vertical, not horizontal. In other words, the set of people who come in the first time is not '4 2 2 17', which is the first horizontal line, but '4 1 5 1'. FYI, I didn't have enough time for this... :(

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

    If we clear any queue at index i then the result for that queue would be sum from i+1 to n for that queue. Now find out the maximum you can obtain from each queue as by induction or simple observation you can see that if you can obtain say 4 from a queue then it can also be used to provide any value <4. Just push these values in a vector and sort them , if some element is missing and there is a number greater than that in the vector , it can be used to fill in the vacancy to increase the mex.

    For you case , the breakdown is as follows: Queue 1 can contribute max 0. Queue 2 can contribute max 1. Queue 3 can contribute max 0. Queue 4 can contribute max 2. Hence the vector would be 0,0,1,2 , the mex for which is 3 If for eg Q2 could also contribute max 2 , then we could use it as a 1 to fill in the gap.

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

    I made the same mistake with the matrix direction. I spent an hour thinking, then came to the comment section for the answer.

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

i was thinking of trying e1 before D because of the score distribution,, glad i looked at the number of submissions ,,

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

In D. Graph and Graph
tutorial: "the number of edges in the new state graph will not exceed m1.m2"
I must be stupid, but please correct me.

The number of edges (E) in the new state graph will be of order 10^3(m1)*10^3(m2) i.e 10^6
The number of vertices (V) will be order n^2((10^3)^2) i.e 10^6.... though we may not visit all vertices here.

But the time complexity of Dijkstra with binary heap is
O(V*(Extract_Min) + E*Decrease_Key) = O(V logV + E log(V))
which here results to (10^6 * log2(10^6) + 10^6 * log2(10^6)) = 2*(10^6 * 20) = 4*10^7

Questions ?
- What am I missing here ?
- How many operations are allowed in 1sec ? if am not wrong is 10^6 simple operations(not %, /)
- How do we calculate time complexity here?
- How many operations are performed here ?

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

for the first problem, a = [2,2,3] => set of a has {2,3}, size=2; b= [2,2,3] => set of b has {2,3}, size=2; so total size >=4. But the answer is 'NO' only 2+2,2+3 or 2+2, 3+3 are possible. Am I wrong or the solution is wrong

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

    premise is a & b are "good" arrays. your a and b arent "good". 3 must occur at least twice

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

Is there a name for the technique in D? I've never seen it before but it's very cool.

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

    It's Dijkstra Algorithm

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

      I know that, I meant the way that the states are tracked in the 2d array

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

        I also wanted to know, the dijsktra on 2d states track also caught me off guard. (I will never thought of that on a whim)

        If I was trying to crack D in live contest, I'd bet it on BFS 0/1 state with max steps = 2n.

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

        In graph theory, when you define a graph, a "vertex" is just not a simple thing with 1 number. A "vertex" in graph can also be a state, such as if you playing chess, each vertex is a chess board and if you play a move, so the old chess board can connect to a new chess board, etc.

        So in this problem, you should consider that a "vertex" is a pair of numbers <u1, u2>. If u1 is adjacent to v1, u2 is adjacent to v2, so "vertex" <u1, u2> is connect to <v1, v2> with cost |v1 — v2|

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

Can anyone help to give the countercase or find the testcase on which my submission for E1 is failing.

My-submission

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

can anybody explain why i am getting a Tle for this submission of mine 304236998 for the problem D.

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

shfs hey I think my submission for E1 seems to work when B doesn't have distinct elements either.

304147683

I tried the following case

1
3 3
1 2 3
4 5 6
7 8 9
1 10 2
1 2 11
12 3 4

and it returns 5 as expected.

I would stress test to make sure I'm right but I'm not sure how would a brute force look like. can you share the brute force you used to test your solution in E1?

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

B is Constructive. It was not able to solve it but it was intresting idea when I saw the editoral

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

For problem B, in the fourth example, the answer is 1

5 4 1 1 1000000000 2 2

I think this is wrong: 4 subarrays [1],[1],[1000000000], [2,2] b = [1, 2, 2, 0]

Why is the answer not 3?

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

Can anyone uphack my solution for B. https://mirror.codeforces.com/contest/2059/submission/304209911

TC :

1

7

6

1 2 2 2 2 3 3

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

kinda suprised D has a lot of solves. Is the idea obvious or pretty standard

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

For D, I did something like :310452937

Each state in the PQ is (sum, s1, s2, zero_cnt), tracking the total cost, token positions in both graphs, and how many times we got consecutive zero-cost move. If zero_cnt == 2, we're done and print sum. Otherwise, keep expanding (u1, u2) pairs and push new states.

Also used visited maps, if it runs too long, i stop it and return -1.

Anyway, still not sure why no tle. Cool question though

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

I think B is the most worst Problem