When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

vovuh's blog

By vovuh, history, 5 years ago, In English

<almost-copy-pasted-part>

Hello! Codeforces Round 570 (Div. 3) will start at Jun/26/2019 17:35 (Moscow time). You will be offered 6 or 7 problems (or 8) with expected difficulties to compose an interesting competition for participants with ratings up to 1600. However, all of you who wish to take part and have rating 1600 or higher, can register for the round unofficially.

The round will be hosted by rules of educational rounds (extended ACM-ICPC). Thus, during the round, solutions will be judged on preliminary tests, and after the round it will be a 12-hour phase of open hacks. I tried to make strong tests — just like you will be upset if many solutions fail after the contest is over.

You will be given 6 or 7 (or 8) problems and 2 hours to solve them.

Note that the penalty for the wrong submission in this round (and the following Div. 3 rounds) is 10 minutes.

Remember that only the trusted participants of the third division will be included in the official standings table. As it is written by link, this is a compulsory measure for combating unsporting behavior. To qualify as a trusted participants of the third division, you must:

  • take part in at least two rated rounds (and solve at least one problem in each of them),
  • do not have a point of 1900 or higher in the rating.

Regardless of whether you are a trusted participant of the third division or not, if your rating is less than 1600, then the round will be rated for you.

Thanks to MikeMirzayanov for the platform, help with ideas for problems and for coordination of my work. Thanks to my good friends Mikhail awoo Piklyaev, Maksim Neon Mescheryakov and Ivan BledDest Androsov for help in round preparation and testing the round.

Good luck!

I also would like to say that participants who will submit wrong solutions on purpose and hack them afterwards (example) will not be shown in the hacking leaders table.

</almost-copy-pasted-part>

UPD: I also would like to thank Ashishgup and kocko for help with round preparation and testing!

UPD2: The contest will be extended for 15 minutes because the problems are more interesting than we thought. We also advise to read all the problems because some of them may have the same difficulty and we cannot know which one will be easier for you than the other.

UPD3: Editorial is published!

UPD4:

Congratulations to the winners:

Rank Competitor Problems Solved Penalty
1 Mbah1937 8 248
2 rtbmnie 8 450
3 BaiBatyr 8 455
4 LJF007 7 305
5 old_boo 7 322

Congratulations to the best hackers:

Rank Competitor Hack Count
1 praeda_est_supra 120:-90
2 Radewoosh 75:-21
3 yzm10 36:-2
4 csegura 31
5 Shaker007 30:-11
798 successful hacks and 492 unsuccessful hacks were made in total!

And finally people who were the first to solve each problem:

Problem Competitor Penalty
A blast 0:01
B Kirill_Kudr22 0:04
C I_love_HellHoleStudios 0:04
D divya_rawat 0:10
E AcceptedIsRealAbility 0:13
F FlyInTheSky 0:42
G Mbah1937 0:27
H UMP45 0:25

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

| Write comment?
»
5 years ago, # |
  Vote: I like it -8 Vote: I do not like it

why I m struggling in Div.3 ? how can I improve my DP & graph solving ability?

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

Hoping for a good contest!! Was awaiting Div3 eagerly.

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

"You will be given 6 or 7 (or 8) problems and 2 hours to solve them." It is so vague. Though It'll be decided later.

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

    The contest is running with no problems showing, i guess they still couldn't decide ;-)

»
5 years ago, # |
  Vote: I like it +36 Vote: I do not like it

Div.Vovuh xD

»
5 years ago, # |
  Vote: I like it -36 Vote: I do not like it

I hope to become purple after this round!

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

    If you solve all problems and take first place, that might be possible

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I hope to become red after this round!

»
5 years ago, # |
  Vote: I like it -22 Vote: I do not like it

I find difficulties of problems from Div 3 are as same as Div 2!

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Why do u think so?

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it -12 Vote: I do not like it

      It's from my experience from Div 2 and Div 3 contests I've participated.

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

        I dont think so. Probably, u cant solve 3 problems sometimes even when u`re blue, but in div3 u can

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I used to think the same when I was around your rating, but once you reach somewhere around 1500, you will notice you are able to solve 4 or more problems in Div 3.

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

        experience ?!!!! you mean solving at most 1 problem in more than 15 minutes in less than 10 contests ? are you sure you know what the meaning of experience is ?

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        maybe it's right when you solve only 1 problem. My experience: 3 div.2 / 4 div.3 (year ago) 4-5 div.2 / 6-7 div.3 (now)

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

          OK, I got it. If I go to advance level I will get the difference. Thank you guys

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

    The creators of the contests have sufficient intelligence to differentiate problems of Div 2 from Div 3. Trust them.

»
5 years ago, # |
  Vote: I like it +18 Vote: I do not like it

Vovuh can stay on top of the contributors table just by organizing 1/2 Div. 3 rounds per month xD

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

Hope I will turn pupil after the round :)

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

    I wish you good luck!

    EDIT: when you get downvotes for cheering someone on xD

»
5 years ago, # |
  Vote: I like it -13 Vote: I do not like it

Good luck everyone, i hope for a good contest for all of us.

»
5 years ago, # |
  Vote: I like it +17 Vote: I do not like it

Tired of helping Vasya and Petya !

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

when these persons are testing the round , the chance of hack comes down a lot !

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It becomes zero in some questions(B) as they have to remove then xd

»
5 years ago, # |
  Vote: I like it -13 Vote: I do not like it

The winner of this contest name will start with 'g'.

MyPrediction

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

DIV-3 contest is always missed by Vovuh. :D :D :D

»
5 years ago, # |
  Vote: I like it -11 Vote: I do not like it

Does the countdown work correctly? It says 7:05 before start!

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

wow new contest from vovuh

i love you man

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

The temperature is higher than my meme contribution

»
5 years ago, # |
  Vote: I like it +32 Vote: I do not like it

where are the problems

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

Unable to see the problems.

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

Not able to see problems. Is it only me ?

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

question is not opening

»
5 years ago, # |
  Vote: I like it -6 Vote: I do not like it

what is going on with interface?

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

why i can't ask an question????????????

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Anyone else not seeing problem statements??

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

WTF

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

But where are the problems. Contest is running without any problem set

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

Oh time is running although there aren't any questions!

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

    seems like, it's gonna be an unrated contest

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      no way ...no one has seen the problems ..they will extend the contest

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

what's happening codeforces..

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

I cannot see the problems.

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

problems aren't visible.. lol

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

Where are all problems? Are we a joke to you?

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

Hello, there is some issue. The problem set is not loading.

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

Why everyone is writing same comment of not able to see the problems ?

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

are there any hidden questions :(

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

I can't see any problems in contest main page.

»
5 years ago, # |
  Vote: I like it +43 Vote: I do not like it

»
5 years ago, # |
  Vote: I like it +13 Vote: I do not like it

Where are the problems, I can not see them

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

I cant enter in this round.Help plz

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

Problems?!!!

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

So many submissions already and i am just receiving the problems... Will it be rated?

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

The problems were not visible and suddenly I saw 3000 people have already solved the first question

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

will there be extra time for the delay?

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

unexpectedly ez round...wish u guys good luck.

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

Yet another internet speed round XD

»
5 years ago, # |
  Vote: I like it +29 Vote: I do not like it

Queryforces

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

problem C is easy but hard to implement...

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    < 10 lines in python for me

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Could you please explain the solution. I mean pseudo code

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        You can consider the formula for how much additional charge you will need, where "out" is the number of days you don't charge: neededCharge = (out*a) + ((n — out)*b) — k + 1 Specifically, we need neededCharge to be less than or equal to 0, so we can set out based on that. Simplify to get out <= (k-n*b-1)/(a-b). So, set out = floor((k-n*b-1)/(a-b)) Then, if out is less than 0, your answer is -1. Otherwise, your answer is min(n, out).

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

can any one explain problem D ?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    store array containing frequency of i in arr[i]. sort all values in reverse order, now for all elements after 1st element in array, its value is min(arr[i],arr[i-1]-1). Answer is sum of positive values in array.

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

Problem E is more easy for Java people

»
5 years ago, # |
  Vote: I like it +48 Vote: I do not like it

Thanks for the contest!

For anyone who had a hard time with any of the problems, I wrote up descriptions of my solutions, which you can find at this link. If you have any questions, feel free to post below.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks, I think it'd be a bit easier to read if you posted this as a blog and if you have the implemented code, to share it.

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

    Thanks for your effort. I looked into it. I found that explanation of Q.F was difficult for me to understand ( or maybe because i have used another method .) Can you tell me in short what you did ?

    My method : I found out during the contest that if there is a solution which doesn't have max element (let's say m) . Then the only better option can be m/2 + m/3 + m/5.

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

      Yes, I think we used different methods (although I know other people who used your approach too). That's a clever solution--my method was essentially a pruned complete search. I noticed that any number under 200,000 can't have too many factors (more precisely, they have at most 160 factors). This lets us considerably reduce the number of possibilities we have to search through, and from there the rest is essentially a bash.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        If I'm not wrong, you take 340 problems as a candidate for first problem , and for each of them you take next 170 as second and 340 as third candidate ?

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

          I took 340 problems as candidates for the first problem, then for each potential first problem, I chose 170 candidates for the remaining two problems. I then did some optimization so that I could pick the best pair of problems in ~170 operations rather than by considering all possible pairs of candidates.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    getting tle in test case 6 problem g https://codeforces.com/contest/1183/submission/56137010

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

How to solve G?

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

    Edit : This is for Problem H.

    Consider dp[i][j] -> number of distinct subsequences ending at i, of length j. Then,

    $$$dp[i][j] = \sum_{c = a}^{c = z} dp[prev[i][c]][j - 1] $$$

    Where prev[i][c] is the maximal index before i, that has value c.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Is there only dp solution? I've tried whole round to think greedy one

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

        i'd say, that this is Dp + greedy

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How does it make sure that only unique subsequences are counted

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      How can we take care of Overflow??

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

Totally, I could not understand the problem C :(

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    it takes me more than 40 min to understand :(

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

    You can consider the formula for how much additional charge you will need, where "out" is the number of days you don't charge: neededCharge = (out*a) + ((n — out)*b) — k + 1 Specifically, we need neededCharge to be less than or equal to 0, so we can set out based on that. Simplify to get out <= (k-n*b-1)/(a-b). So, set out = floor((k-n*b-1)/(a-b)) Then, if out is less than 0, your answer is -1. Otherwise, your answer is min(n, out).

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

How to solve E?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    dynamic programming dp [i] [j], the number of different strings of length i ending in j letter

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Could you explain how do you ensure that we don't count the same string twice while building the dp. Thanks in advance.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Try to understand it yourself. Let's get another matrix used [i] [j], indicating whether there was such a state before. If it was, we simply reset dp [i] [j] and recalculate the answer for it since this time we will have more different lines of length i ending in j.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Actually BFS is ok...

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

In test case 4 of E why cost int not 232 — 1*0 + 10*(10-9) + (C(10,2) = 45)*(10-8) + 44*(10-7).

UPD : Got it. I made a mistake.

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

why there was no hacking ? and when the ratings will come up ?

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

    In Division 3 rounds, hacking occurs for twelve hours after the contest. Ratings will update after the hacking phase and system tests finish.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Thank you for your explanation would you tell me how to hack somebody now ?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The Hacking phase in Div.3 comes after the contest like educational round

    The rating will come up after finish the Hacking phase

»
5 years ago, # |
  Vote: I like it +6 Vote: I do not like it

great round I would say but the complexity of the tasks > D is quite high for a Div. 3 contestants

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

Damn I could solve E I think.. isn't it trying all the possibilities and if it took too long we would output -1

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

    No its not you wold definitely get TLE or WA for that the solution . just consider a 100 letter string with same characters and k=99. you can use dynamic programming to solve it.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yup it's no good to solve it like that I will try it later

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Why DP. I thought it is a implementation type problem. I got pretest passed without DP.

      • »
        »
        »
        »
        5 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Yes I thought of an implementation solution like yours but unfortunately I wasn't able to solve the hard version with it so I used DP to solve both of them.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      It is possible. My (updated after contest) solution: http://codeforces.com/contest/1183/submission/56154439

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

        what do you mean by possible . I'm sure you didn't simply tried all the possibilities inefficiently.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          I tried all, but stop when I achieve k number of possibilities. Sure, it's not fair "all". But it's kind of brute force.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Hahaha, trying all possibilities? Did you read "substring" instead of "subsequence"?

    Just as a side note, total possible ( without removing repetitions ) number of subsequences is $$$2^N$$$ where $$$N$$$ is the length of the given string.

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

      Did you read reza comment .. yeah I get it and I know the possibilties could be large but I thought if we didn't find 100 substring after 1e8 possibility then there's no answer but as reza said 100 same letter wouldnt work with this way

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

        Oh my bad then. But you didn't clearly mention what you were going to do? I accept I misunderstood here, but you should have said something like "Since $$$K$$$ is small, we can just find those many subsequences and then stop". This gives better idea of what you were trying to convey.

        Anyhow, I must apologize for my misunderstanding. Sorry for that! I shall read more carefully from now on.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          yup i got Accepted with your approach :)

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

can I hack my own solution???????

»
5 years ago, # |
  Vote: I like it -7 Vote: I do not like it

The user _Md_AL_AMIN_ cheated again.

He somehow find the solution of problem H of sraman915

Submission by sraman915: 56104958
Submission by _Md_AL_AMIN_: 56124086

I think he should be banned from Codeforces as he did cheating multiple time. The another cheating caught by me is here

I am drawing attention of MikeMirzayanov

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

    Who are you LE_ROI? :D :D :D If you can prove this I will give you everything in this world. Please don't wast your time to see other code. Nijher chorkai tel dao. Copy past codeforce onek valo dhorte pare. I don't know who is sraman915. Hey Sraman are you know me? LE_ROI are you man or woman? :D :D :D

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

    The question is all about finding the distinct subsequences of length K. after that one can easily figure out the solution. I googled it and found something relevant which I have also mentioned in my code.

    I don't know _Md_AL_AMIN_ but after seeing his solution I think he has also used the same thing but he forgets to mention in his code.

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

      Yes, you are correct. But I don't copy and past. I just use google to find out finding the distinct subsequences of length K . Thanks you sraman915.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Hey. I have also taken code from that site, although I was not sure whether I should use that code. Are we allowed to take code from other sites during contests?

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

        Yes, googling is a must skill. It does not violate any rule of CF.

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

        You can take any code that is not copyrighted except the code from current participants of the contest.

        • »
          »
          »
          »
          »
          5 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Okay. Thanks for clarification.

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

    It seems he has copy and paste code from Internet source. It is clear from inconsistent indenting. Many people have done this. I don't believe he has cheated.

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

TIL that declaring a massive vector makes a big difference in time complexity. (vector (MAX)) https://codeforces.com/contest/1183/submission/56113733

https://codeforces.com/contest/1183/submission/56126400

https://codeforces.com/contest/1183/submission/56126075

https://codeforces.com/contest/1183/submission/56126321

I thought that declaring a vector only takes up space and not time.

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

TLE https://codeforces.com/contest/1183/submission/56117801 AC https://codeforces.com/contest/1183/submission/56126830 The only difference between 2 submissions is I declare the array inside main

Why I got TLE ?

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

    Have a look at my submissions I got plenty of TLE's for the same reason on D. When you declare your array globally of size 2e5 and when there are 2e5 queries it will become O(10^10) because you are initially array of size 2e5 everytime. That's why array should be dynamic to take advantage of the fact that the sum of n over all queries is <2e5.

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

How to solve G?

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

When I tried to hack others solution with my testcase.I am getting generator crash error Since it is valid. My test case is : : test case

(for Problem D )

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    It is because you are generating a testcase with 200000 queries where n=200000. However, in the problem statement, it is mentioned that "It is guaranteed that the sum of n over all queries does not exceed 2*10^5 ".

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

Hello i am very new to codeforces will anyone tell me that after participating in div 3 and solving 2 questions why there is no effect on my rating??please tell me Thanks :)

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Right now, hacking phase is going on which will continue for 12 hours. So, ratings will be changed later after the hacking phase ends.

»
5 years ago, # |
  Vote: I like it +4 Vote: I do not like it

can anyone explain..how to use DP in problem E?

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

    Sure. Sub-problem : Count number of distinct subsequence in a string ? Sol — I'll use 1 based indexing. Let DP[i] be the number of distinct subsequnces ending with character s[i]. Then if character s[i] did not occured before then we can chain it to all distinct subsequence occured before this position i.e. we can freely choose second last position in our subsequence DP[i] = sum of all DP[j] for j < i. If s[i] occured before then we don't need to count second last position before last occurence of s[i] because they are already calculated DP[i] = sum of DP[j] for prev[i] <= j < i. where prev[i] = last occurence of s[i]. Base case is empty subsequence. DP[0] = 1.

    Original-Problem — Just add length state in DP. DP[i][j] = Number of distinct subsequence having last character s[i] and is of length j . Base case DP[0][0] = 1.

    This solution is O(n^3) but can be optimised to O(n^2) by calculating prefix sum DP for each length layer.

    While finding best cost in problem : Start taking subsequence with maximum length.

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

very nice round . congrats

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

Can somebody please explain the graphical approach to problem E?

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

queries round.

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

can somebody explain how you think problem B solution thanks in advance

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In B we have a sure move to maximize the common price, if that is not possible there can't be a common price.

    After sorting the prices, if we increase the smallest price by k(maximum possible increase), and if the product with largest price is less than a[0] + 2*k, then there exist an increment or decrement of a value less than k to reach that maximum possible price. But if the product with largest price is greater than a[0] + 2*k then there is no such price that the smallest and largest initial price product can have in common.

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

Can someone please review my solution for B: https://codeforces.com/contest/1183/submission/56089281

I think I got lucky, since I don't even know what I was intending to do. My logic made sense in the start, and I kept changing the conditional to pass the example input.

Perhaps it will not pass sytem tests.

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

    I think your solution is correct. After sorting the array, to print (a[0]+k) as answer, we need to just check if (a[n-1]-k)<=(a[0]+k) or (a[n-1]-a[0])<=2*k. Instead of checking only for a[n-1] (or max element), you are checking for all elements which is not necessary. So it should pass system tests.

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

Problem statement of C was not good, it took me around 30-40 minutes to understand the problem statement.

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

Good round and good tasks. Thanks, vovuh!

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

Will hack score?

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

How can I figure out what's wrong with my code when I get a WA on a mile long test case?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Create a program that generates a (small) testcase, generate one as long as your output equals to the output of a bruteforce/copied model solution.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      The solution itself is more or less bruteforce plus I tested the code for a lot of small cases by hand so I'm really surprised that I get WA

»
5 years ago, # |
  Vote: I like it +2 Vote: I do not like it

The best div 3 I ever seen. But different in complexity between D and E was too hight.

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Hey codeforces ,

Please check my blog where I have revealed a big fraud that happened in today's contest !

What these two users did is just unbelievable, I hope MikeMirzayanov will do something about the subject.

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

problem G getting tle on test case 6 https://codeforces.com/contest/1183/submission/56137010

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

My solution I'm getting trouble with problem B. Could anyone tell me what's wrong with my approach?? please...

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

any help pls!,why this code fail in test 3 problem B? https://codeforces.com/contest/1183/submission/56142029

»
5 years ago, # |
  Vote: I like it -8 Vote: I do not like it

how to solve E?? plz someone explain it in simple words

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Use breadth first search. Nodes are strings. Edges is removing one character from it. Use map or set to remove duplicates.

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    For E u can simply bruteforce...Generate unique strings by deleting 0,1,2,3... characters from given string until size of 'S' becomes K... To generate all string u can use a queue of string and push the given string into it now take the front of queue, generate and push all unique string by deleting a character from it. Repeat this until queue becomes empty... You can refer to my submission

»
5 years ago, # |
  Vote: I like it -29 Vote: I do not like it

One of the worst contests ever. Terrible test cases, and for some reason, all questions had the same weight which doesn't make any sense.

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

Does our rank go up if we do successful hacks?

»
5 years ago, # |
  Vote: I like it +9 Vote: I do not like it

Editorials?

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

Interesting problems.

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

systems message:"Внимание! Ваше решение 56108275 по задаче 1183E значительным образом совпадает с решениями других участников и находится в группе одинаковых решений lukamosiashvili/56108275, Whatever.../56123536. Такое совпадение является явным нарушением правил. Отметим, что непреднамеренное утечка тоже является нарушением. Например, не следует пользоваться ideone.com с настройками по умолчанию (публичным доступом к вашему коду). Если вы имеете неоспоримые доказательства, что совпадение произошло по причине использования общего источника, опубликованного до соревнования, то напишите комментарий к посту о раунде со всеми деталями. Подробнее можно прочитать по ссылке http://codeforces.com/blog/entry/8790. Такое нарушение правил может являться основанием для блокировки вашего аккаунта или других штрафных санкций. В случае повторения нарушений, ваш аккаунт может быть заблокирован." I can not wonder how he copyed my code, because I not gived him my code.

»
5 years ago, # |
  Vote: I like it +6 Vote: I do not like it

Where Is The Editorial?

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

any editorial/tutorial please? :)

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

    https://codeforces.com/blog/entry/67973

    unofficial and please stop making these comments before reading other comments in here, you're creating useless messages which waste people's time when you could have just scrolled up a bit and found what you were looking for.

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

The test case in problem c on which my code was hacked is showing same solution on one of the correct submissions .Are there any other reasons of a code getting hacked ?

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

Where can I get editorial of this contest?? Plz help

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

Can someone please explain how to solve the last problem(H)?

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

Wow, this is my first time on the list!! Happy:)

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

This may sound dumb but I still dont understand Problem C- Computer Game. What is different between output 0 and -1?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    NOTE: In the first example query Vova can just play 4 turns and spend 12 units of charge and then one turn play and charge and spend 2 more units. So the remaining charge of the battery will be 1.

    doubt: TEST CASE: 15 5 3 2 If Vova can play 4 without charge and then 1 turn with charging then why is output 4?

    Help would be really appreciated

    • »
      »
      »
      5 years ago, # ^ |
      Rev. 5   Vote: I like it 0 Vote: I do not like it

      It’s all based on the completion of this game. In worst case you may output 0, otherwise output -1 when Vova cannot complete anyway. Vova can complete only if after each of n turns the charge of the laptop battery is strictly greater than 0. If it is equal to zero, it can only output -1, but it is not good.

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

I am a begginer and most of my codes face TLE.Please suggest?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    keep in mind the constraints and optimize accordingly

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

If you are Python programmer, consider using C++ instead of Python when you submit your code

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

what is wrong in my code;

include

using namespace std;

int main() { int a,n,b,d,c; cin>>a; d=a; while (d != 0) { b = d % 10; c = c + b; d = d / 10; } if((c%4) == 0) {cout<<a; } else {n=c%4; a= a+n; cout<<a;}}

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    You should write a loop to find a bigger answer than "a" in the else statement.