DS007's blog

By DS007, 4 years ago, In English

Hello Codeforces!

I am pleased to invite you to my first contest Codeforces Round 695 (Div. 2), which will take place on Jan/08/2021 17:35 (Moscow time). The problems were written by alimq and DS007. The round is rated for all users with rating less than 2100, while other users can participate unofficially.

You will be given 5 problems and 2 hours to solve them. You are strongly advised to read all the problems.

I would really like to thank:

  • BledDest for his amazing coordination of the round.
  • Aggu_01000101 and infinitepro for helping me in shortening the problem statements and solving one of the problems.
  • MikeMirzayanov for creating the Codeforces and Polygon systems.
  • The following people for testing the round:
Geothermal
sahil_k
dorijanlendvaj
eggag32 awoo
Roms Java
stefdasca Aggu_01000101 kostia244
fishy15 Gilgameshx vrooooom
T1duS wabadabakalakaboo neko_nyaaaaaaaaaaaaaaaaa
SleepyShashwat BRCode infinitepro
flamestorm saarang123 geekpradd
Jellyman102 manish.17 1_2_oatmeal
anuragbhatt socho kshitij_sodani

We hope you will enjoy the problem set! Good luck!

The scoring distribution will be added shortly.

UPD: Also thanks to nooinenoojno for testing the round.

UPD: The scoring distribution is: $$$500 - 1000 - 1500 - 1750 - 2500$$$.

UPD: Congratulations to the winners

Of div 1:
1. kort0n
2. Suiseiseki
3. peti1234
4. fastmath
5. wrinx

And of div 2:
1. raingirl
2. xsdns
3. Mister5
4. o.a
5. 20I6wudi

Thank you all for participating! My apologies for misjudging the difficulty of B.
Editorial

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +722 Vote: I do not like it

As a tester, I have a proof that upvoting this comment will lead to positive delta. But the proof is too long to fit the margin.

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

As a tester there are 1 AI and 4 DS problems

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

As a tester, I Can confirm that DS007 is a wonderful dancer.

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

As a tester, I'll edit this comment later and add something witty.

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

    Seems like it was quite difficult for DS007 to fit you in the above tester arrangement, which itself is pretty cool, I hope there would have been more diversity in color(given we have new year magic)

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

      Isn't the colour arrangement pretty cool though? It's the CodeForces logo!

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

        Indeed it is, but would be much better if we can have you also in that arrangement :P

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

        Ahh my bad, seems like you are already there in expert's color :P

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

          Yes :( The real CodeForces magic was that the website somehow detected my true skill level :(

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

            As a tester, I can confirm I'm actually red

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

This should be great contest. Good luck to everyone!

»
4 years ago, # |
Rev. 8   Vote: I like it +162 Vote: I do not like it

I'm the (official) meme supplier for this contest. For every 69 upvotes, I'll upload a new, original content, cp related meme.

#1
Free Sample #1
#2

See this post for latest memes.

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

Good luck to everybody and to me also

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

Wow, no wonder you said, You had a lot of testers for this round earlier. Looks like a lot of effort went into the preparation of the round, looking forward to it. Also any authors of future rounds who are looking for testers, I would be happy to help.

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

Let's wait till 11/01 to see the tester table messed up. Unless it will be changed later.

»
4 years ago, # |
  Vote: I like it +119 Vote: I do not like it
Spoiler
»
4 years ago, # |
  Vote: I like it -7 Vote: I do not like it

only 192 more for pupil rank :D (lmao I'm not still good and I don't know why I'm happy)

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

    Only 97 for specialist. But I know i'm gonna decrease again. :)

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

(bccf)

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

I tested this contest and it was good.

»
4 years ago, # |
  Vote: I like it -81 Vote: I do not like it

As a tester, give me contribution! Also suggest me a new profile photo, I removed mine temporarily.

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

    You got contribution even as a non-tester! Not positive though, but still you didn't specify what kind of contribution. May consider doing this in future myself.

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

I like how the testers' names are arranged in order of the lights to the left of the logo!

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

    Imagine getting rejected as contribution farmer tester just because cf logo will not look good in the announcement.

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

      LMAO. Still, you gotta appreciate the effort though XD! For the testers to change their ratings so much and for DS007 to properly format it.

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

Indian Round .

»
4 years ago, # |
  Vote: I like it -9 Vote: I do not like it

pog

»
4 years ago, # |
Rev. 8   Vote: I like it -51 Vote: I do not like it

»
4 years ago, # |
  Vote: I like it -20 Vote: I do not like it

I hope everyone rating goes up in this contest

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

As a non tester Chaliye Fodte hai ;)

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

Hope a good result for everyone !

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

It's advised in the post to read all the problem statements. Does that mean the problems won't necessarily be in increasing order of difficulty?

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

As an idler, there are too many useless spoilers on this page, so one can use this script in the console to expand them all:

$(".spoiler-content").map((i,val)=>{val.style.display="block";})
»
4 years ago, # |
  Vote: I like it +5 Vote: I do not like it

SPOILERFORCES

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

Guys don't waste your time in B and C like me. There is always an easier approach and everytime I think of an overkilled solution.

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

    You may consider rethinking your strategy after this contest...

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

    I feel you bro :'(

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

    ALways start from harderlike D or E onwards as cheaters can't ruin them easily. Also you may get first to solve award for a problem with that startegy, Last contest I would have solved Div2 D as the first person to solve but I got a silly error thus finished it after 7-8 people.

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

    Guys guess what?? Again I overkilled the solution of problem B. Although i solved it but wasted a lot of time. XD

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

Love this comment section

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

There are only 3 ratings left before I can be a Master(without using "magic")!Hope I can do it!

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

I hope no one cheats in today's contest.

  • »
    »
    4 years ago, # ^ |
      Vote: I like it +29 Vote: I do not like it
    How to decrease mass cheating ?
»
4 years ago, # |
  Vote: I like it -10 Vote: I do not like it

Just two hours left in the contest and still not able to see the score distribution for problems.

»
4 years ago, # |
  Vote: I like it -9 Vote: I do not like it

Ok

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

If the contest gets 20k participants, I'm going to post 25 high quality memes.

Plus, DS007 promises a div1+div2 contest in the near future if this contest is well received...

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

scoring PLS

»
4 years ago, # |
Rev. 2   Vote: I like it -22 Vote: I do not like it

Is it rated for newbie?

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

    i think u did not read the contest announcement (The round is rated for all users with rating less than 2100)

»
4 years ago, # |
Rev. 2   Vote: I like it -53 Vote: I do not like it

.

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

    Don't generalize a bad deed to many people, especially when lots of them are helpful and honest :D

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

    Indians aren't cheaters. Don't generalise something to whole community. It's not a good thing.

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

good luck

»
4 years ago, # |
Rev. 4   Vote: I like it -18 Vote: I do not like it

div2A is kind of diffcult >_<

I think we could add a problem in front of this and make a 6 problem round.

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

it's been only 30 minutes and I already hate this contest.

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

    Even Masters are struggling, now that's tough

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

      No,masters just close the website and enjoy their life because they're unrated.

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

I think authors should not make problems anymore

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

Describe the contest in 1 line: Wrong answer on pretest 3

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

The round of Wrong answer

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

deleted

»
4 years ago, # |
  Vote: I like it -30 Vote: I do not like it

Contests 2021 is so boring !!!

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

Deleted

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

I am in doubt this is a div2 round ...

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

    I have a similar doubt too. Looks like a DIV 1 I guess. One thing which presents always while submitting my code i.e--"W.A on pretest 3". Disappointed after giving today's contest. :(

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

well there goes my expert

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

As I can see from my friends standings this contest has been a total mess.

»
4 years ago, # |
  Vote: I like it -9 Vote: I do not like it

it is been more than half of the contest and less than 3000 one solved b :o , i can say that this is a big mess

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

Pretests for B are too damn strong. Kudos.

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

    Better strong than weak. Would you really want to fail a system test?

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

Just waiting for time to end and someone tell me all I did was miss an edge case to get Wrong Answer on Pretest 3 :(

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

    You can try this;

    1
    7
    1 10 5 2 7 4 1
    

    output:2

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

I am actually curious to see the standing of the testers' virtual participation.

»
4 years ago, # |
  Vote: I like it +98 Vote: I do not like it
CF #695 IN A NUTSHELL
»
4 years ago, # |
  Vote: I like it +17 Vote: I do not like it

Div2-B Pretest 3 is KILLER !!!

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

What the hell is this Pretest 3 in B

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

SOLVED C but Failed B. this is CODEFORCES EFFECT

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

No way this was a DIV 2 round

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

Too hard!!

»
4 years ago, # |
  Vote: I like it -15 Vote: I do not like it

Really confusing statement for A, or so it appeared to me. Although they explicitly mentioned $$$|x-y|$$$, I had considered array to be circular in my mind. Even the examples satisfy the circular array assumption.

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

    Same, I to get WA on pretest 3, not able to solve a single question, RIP my ratings ;-; :( ;-;

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

WA on pretest 3

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

The most evil: "Problem B pretest 3"

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

I probably misread Div 2

»
4 years ago, # |
Rev. 2   Vote: I like it -7 Vote: I do not like it

To the people complaining — Div2B is all about a simple brute-force, so yes — you've read that right — perfectly suitable problem for Div2B. As for the Div2C I believe it has to do something with finding the two minimum elements and a few corner cases, but wasn't able to solve it fully.

Overall a great contest! Really challenging and interesting problemset! Thanks to the authors for such an amazing contest!

EDIT: Again downvoted for saying truth — newbies go be real mad. Y'all expect to solve 3 problems and stay pupil? No, that's not how it works. Back in the day, people who solved 2 problems fast could reach 1700 — because problems used to be tough. Trust me — no improvement if you do only easy problems.

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

    I don't know about rest of the comment but yes challenging problems must be welcome

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

    Downvoted, I don't like when D2B is bruteforce. Am I newbie?

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

      I didn't call people newbies for not liking D2B bruteforce — just not being able to figure it out in 2 hours really doesn't deserve any higher rank. I was very scared when It took me over 30 minutes to get such an easy problem right. It's really a standard thing these days to see D2B done using brute-force.

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

      D2B was not a bruteforce, it was $$$ifififelseifelseelseififelseelseififelse$$$.

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

        It was brute-force without many ifs if you are smart about it. Take a look at my code and compare it to yours.

  • »
    »
    4 years ago, # ^ |
    Rev. 2   Vote: I like it -13 Vote: I do not like it

    Agree that this was a nice contest. Couldn't complete finding C corner cases. It was a hard fight and annoying.

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

    In my opinion B was "hard" for the wrong reasons. Most people at the Div 2B level can definitely understand the solution for B. The most pleasant word I would use to describe today's B is not "hard", but "tedious": had the right idea and most of the details early on, took forever to find the missing corner case.

    Also, it wouldn't be such a big deal if the very next problem, C, wasn't yet another "figure out the cases" problem 0_0.

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

      Again i will say — no special case exists in Div2B. Take a look at my accepted code.

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

        Ignoring template my code is shorter than yours .___.

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

          But it's more bug prone. I was 100% convinced my solution would not fail, while it took you more attempts to get it right.

          I'm not disapproving your knowledge in any way, just to be clear.

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

      I don't think B had a special case... You just needed to implement it carefully.

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

    did you lost your mind??

    Div2 B are generally of rating 1200-1300 and this contest's div2B is of rating 1700. This is the most unbalanced contest.

    Its easy for you to say these things because simply you are expert.

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

Got stuck even on B. As a result, return to the cyan :(

How to solve B and C?

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

    B is brute force. Change each character so that it is equal to one of its neighbors and "carefully" calculate the change of cost for only the subarray where the change has an effect. Then do the same for the other neighbor.

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

      Change the character $$$a_i$$$ to previous $$$a_i$$$ or to the next $$$a_i$$$? I did so, and got WA 3 :(

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

        I got a nasty bug where I did not check if the neighbors that were previously not a hill/valley became a hill/valley after changing the value of a[i]

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

        Change to both, and see which one gives you a better result.

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

        Also, if $$$a_{i-1} \neq a_{i+1}$$$ you might try something between them, like $$$\frac{a_{i-1} + a_{i+1}}{2}$$$

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

      With this exact approach I submitted 7 wrong answers, still unsolved. Can you share a clean implementation?

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

        Brother you might be missing that after changing A[i] to A[i-1] what is the impact of A[i-1] on A[i+1]. initially I was also missing this but got AC after i checked it.

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

          I did realize this later but i guess i suck at implementing. Thanks

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

getting wrong answer on pretest 3 for B question ,can anyone give any test case

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

quite a peculiar contest many people had the first problem wrong in the first attempt and even the second question. loved the contest by the way

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

Those who failed B, try this

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

    My answer is 1 1 and still getting Wrong answer on pretest 3.

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

    Got 1 to both, for the incorrect submission of B. Any other Test Case?

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

    My solution passed these tests and got WA 3 :(

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

    Ah, got it. Thanks mate! Was trying to find the mistake for 1.5 hours!

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

    thanks !!! was thinking along the same lines but then decided to move on to question 3

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

    Try this also:

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

    thanks it worked for me

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

Who made these problems is an evil person ...

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

Since contest is over, may I get some hints on how to solve problem C?

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

    I replaced a[i] for 1<i<n with both adjacent elements one by one and then counted minimum for all the 1<i<n. It passed.

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

    Without loss of generality, lets assume that the final element will belong to bag A.
    Now, think of the problem as ans = a1 + a2 + ...an + -b1 + b2 + ...bn + -c1 + c2 + ... cn
    (Move all but 1 element in A to B. Move all but 1 in C to B. Move all but one in B to C. Now move all back to A. So all the elements except the ones unmoved in B and C will have a -(-) positive contribution to the sum.

    There is one more possibility. Assume c1 was infinite, so a -c1 is not affordable. So we move all Cs to B and then to A, and ignore moving B twice.
    Answer in this case will be Sum(A) + Sum(C) — Sum(B).
    Swap A, B, C and find the max case. 103801386

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

      This outline makes complete sense. Such a short solution for such difficult problem! Beautiful

»
4 years ago, # |
  Vote: I like it -9 Vote: I do not like it

My mistake from past 30 or so minutes

if(!isValley(idx, arr) && !isValley(idx, arr)){
}

instead of

if(!isValley(idx, arr) && !isPeak(idx, arr)){
}

and that happens despite using an IDE that warns against this :)

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

Who wants to hear how we, the testers, trolled the cheating telegram group? Lot's of WA are cause of our efforts.

To those who want to help: Search for solutions of B that have a -25 anywhere in the code. Post their names here, they are all cheaters...

Reason why? Will make a blog post "soon".

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

    Upvote for calling testers of this round to be called batmen/women

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

    Yes, interested to hear that.

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

    Couldn't you have made some good problems instead of doing this? Many masters have struggled to solve A, B?? The problems were too random. The setters of this contest should not be allowed for any further rounds.

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

      No they weren't. The problems were actually on easier side as later ones were standard. But it was diverse round.

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

Some thoughts after solving B:

If you wrote exactly once in bold why couldn't you write or let the sequence remain unchanged in bold as well?

Why can't n be just greater than 2?

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

    Agreed. Why would you want us to handle n = 1,2 separately? Just make n > 2.

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

    "In the second test case, the best answer is just to leave the array as it is." This is the sample explanation so it was mentioned there.

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

      The second test case will give the same answer when you do exactly one change (change the last 2 to 3). I agree that we should be more careful while reading the problem statement but I just thought it would have been better if it would have also been mentioned in bold that we can perform no changes also...

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

        spooky's comment would make more sense then. It was still mentioned in the explanation of sample cases.

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

        why is mentioning that no change is allowed sush a big issue. if u really wanted to do that you could just increase or decrease a particular number such that it does not make any difference. it was asking to print the minimum intimidation number not the steps required for that

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

    It says "You can change exactly one integer...", which has the meaning you can do, or do not.

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

    LMAO lol I had no idea what was wrong with my program and yeah, it was the fact I did not account for n = 1 and since I now use c++ instead of Java it did not say index out of bounds.... That's honestly stupid.

»
4 years ago, # |
Rev. 2   Vote: I like it -33 Vote: I do not like it

tricky contest XD

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

Div2 C I think I figured out... I was not sure though: is it just total — 2*(smallest + second_smallest) ? D was easier I thought...

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

    Nope for C counter example 1 1 1 3 4 5 Answer 6

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

      What is the counter-example? Like which ones belong to which list?

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

        It's like each list is of length 1. Take 3, 4 and 5 as elements of different lists.

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

        i dont know how to put "newline" in this comments. You have 1 element in each bag,in the first one is 3,the second 4 and the last one si 5.

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

          Two spaces after line is newline here

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

          All good — I understand your test. Looking at the submissions that seem to be passing for problem C, it seems like they used what I mentioned but adjusted it a bit for the edge cases :(

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

    No, I did that and failed test 3.

    Counter example can also be:

    1 1 1

    1 1 1

    Correct answer 1, we print -1.

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

    will fail on this

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

    except when smallest and second smallest are from same bag. In that case its min of that and total-2*(min sum in any bag). correct me If am wrong.

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

    You have two cases.

    1. total sum-2*(smallest + second smallest) (as you said). (Find the minimum of all 3 sets and take the smallest and second smallest)
    2. sum of two largest sets — the smallest set sum.

    Take the maximum of both cases

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

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

In my opinion only fault was it was of 2 hrs . It should have been half or 1 hour more.

Problems weren't straight forward and samples didn't gave any hint and that's why accuracy in this contest was low. But contest wasn't that bad.

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

    This is the worst contest I have ever seen

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

      Problems were difficult thus i think more time would have worked. Except difficulty was there any other issue ?

      Please don't down vote the blog , no one intentionally wants people to perform bad . At least we can appreciate that it was not typing test.

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

    Ya, even i solved the third problem exactly 2 minutes before the end of the contest and couldn't even read problem D

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

I am eagerly waiting to see the 3rd test case of problem "B".

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

Problem solved

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

    I am getting 1 but still WA on pretest 3

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

      yeah, there is also one test:

      Test case 2

      by SarthakBansal

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

        How is this 1 1

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

          I checked this out on the paper and that's true. Just because in both cases you can not rid of all from 1 mountain or hill. You can try to do it on the first test picture:

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

I'm not exactly in a position to say this, but I think pretests for E were too weak. Let's define an array occ[1e9], where occ[i] represents the number of nodes with assigned number equal to i. Then my solution worked in O(sum(occ[i] ^ 2)), which on worst case is O(n ^ 2), and for some reason pass the pretests without much problem. I guess that's because my solution is too counter-intuitive to even think of, but allowing any kind of O(n ^ 2) to pass is in my opinion a sign of very weak testcases.

Note: I'm not saying anything about the main tests, I do hope that some in-contest hacks will be added to break my solution (post-contest hacks will surely break it). However, I suspect this is not the case since there were only around 100 accepted solutions for E, and I've not seen a hacked solution in-contest.

UPDATE: So thankfully (or not?), a new test was introduced to break my solution. My opinion holds though.

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

My wait for cyan continues....

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

Respect ! To those who solved B from the first submission !

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

Excuse me for saying this .. There are two points that make this contest bad : You have underestimated it as Div2 ,,,, The tests were not enough to fully understand problems

»
4 years ago, # |
Rev. 4   Vote: I like it -14 Vote: I do not like it

Very interesting round, first time I've had to write a brute-force for A and B to debug my fast-but-WA code.

For those facing WA in B, here is a brute-force solution and a test harness in python.

Brute-force solution
Test harness
»
4 years ago, # |
  Vote: I like it +33 Vote: I do not like it

On the positive side, fast system testing.

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

system testing on nitros. so much lesser submissions relatively.

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

In C, can we take a and b from the same bag? The problem statement makes it sound like we can't, but then I don't really see how the answer to the second test can be 29...

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

    (7 5 4) (7 1) (2 9)
    (7 5) (7 (1 — 4)) (2 9)
    (7) (7 (1 — 4 — 5)) (2 9)
    (7) (7 (1 — 4 — 5 — 9)) (2)
    (7) ((1 — 4 — 5 — 9)) (2 — 7)
    ((7 — (1 — 4 — 5 — 9))) () (2 — 7)
    ((7 — (1 — 4 — 5 — 9) — (2 — 7))) () ()
    (7 — (-17) — (-5)) () ()
    (29) () ()

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

    Put the 9 in 2nd bag with the 1 in 3rd bag making it -8

    Put the 7 in 3rd bag with the 2 in 2nd bag making it -5

    So the bags now have

    7 5 4

    -5

    -8

    I think you will be able to make 29 from here.

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

For Task $$$B$$$ The maximum no of hill/valley we can destroy by changing a number is $$$3$$$ right?

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

    The best possible case is when changing an element, the answer decreases by 3, however, you have to be careful because many corner cases may exist.

    What I did was: for each position $$$i$$$, I have some options. Keep the value of $$$v[i]$$$ the same or for each $$$j$$$ $$$(i - 2 \le j \le i + 2)$$$, assign $$$v[i] = v[j] + 1$$$ or $$$v[i] = v[j] - 1$$$ or $$$v[i] = v[j]$$$.

    Therefore, I just have to iterate over all these possibilities and see which one is the best.

    Note that for each possibilty, I just need to recalculate the answer in the interval $$$[i - 2, i + 2]$$$.

    My code: https://mirror.codeforces.com/contest/1467/submission/103779093

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

is my idea for B totally wrong ? We can at most decrease the hills and valleys by 3 because at most we can affect 2 hills and one valley or 2 valleys and one hill how could I be wrong about that

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

    Can most decrease by 3 — correct.

    Code with too much ifs must not exist never. Sure thing either one case is missing or misprinted.

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

      I guess there's a stupid bug in my code that I didn't notice the idea is correct

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

    yes but when you have a hill and valley adjacent, flattening a valley may give rise to a new valley eg: 15 10 5 20 17, here when you try to get rid of valley 5 , you must make it >=20 but that would make 10 a new valley

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

      Yeah I tried to change the hill or valley to one of the two adjacent values and took the best change
      my code is just terrible I should have found a better way to code it

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

    Well that part isn't wrong

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

This contest was a trap. :))

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

Another Div 1.5 Contest.
Those who submitted A and B in one go without wrong answer on pretest 3. Hats off to their accuracy.

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

Rozen Maiden one-two finish with Suiseiseki :)

»
4 years ago, # |
  Vote: I like it -9 Vote: I do not like it

Next time Don't believe on a new setter too Quickly!!!:(

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

    Dude, he is making contests, actually making actual contribution to the community. What have you done to do the same? It's pathetic to see the entitlement which participants seem to have. Even I had a terrible contest, but I wouldn't take it out on the authors. Try to give constructive criticism, if possible or don't comment at all :)

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

Very weak pretests for C :(

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

The contest is fun and annoying at the same time as "WA on pretest 3", corner cases killed my rating :)) Anyway, I like it :D

»
4 years ago, # |
  Vote: I like it -15 Vote: I do not like it

why contest div2 was too hard ???

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

What type of div2B has <30% passing rate smh

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

    Yeah, many people got stuck on QB... QC is relatively easier imo

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

      If you don't spend a lot of time on B, that is...

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

Fastest system testing.

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

Just asking, did the testers give no feedback about the difficulty? It would be much better if there were one more problem between A and B.

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

Problem B WA3: When you replace a number, you may not improve the answer, but rather make it worse. Most likely, you only checked the destruction of valleys/hills.

Example:
1
6
6 7 10 5 7 9
answer(1), your answer(0)

Your program will replace the number 10 with a smaller number X. Then most likely there will be a hill (6, 7, X). It was necessary to make a separate check for this

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

My PyPy 3 O(N) solutions TLE for both A and B. What is going on this contest?

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

    Update: I submitted exactly same code for problem B and get AC after the contest, with passing time of 960ms. What a great feeling LOL.. if python O(N) cannot pass TLE during contest, I suggest naming it a C++ round.

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

      Yeah, 1 second really is quite harsh, it's not like 2 seconds would have permitted any n² solutions or anything.

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

        Yes, I agree. Sometimes I have seen when O(NlogN) PyPY will not pass, but this is the first time to see O(N) not pass. I don't mean to serve too many sour grapes, but it's my 39th contest, and first time not solving A or B. It does seem there is something with this round. I know CF is for more for CP, so maybe it's my own fault for using python.

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

Usually when I did not that well I complain about bad problem statements, so I do not write this often, but:

I liked this problemset. Of course, A and B where less simply than expected, but nevertheless solveable. I did not solve C and D, but was close to D. And all the problems were exciting to solve.

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

    For a 5 problem contest I think A was simple enough (just think about first 3 digits is not so hard). I ruined my contest because I wrote on C v[N][5] instead of v[5][N]. For me B was impossible and D some math problem, interesting overall.

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

WA on test #695: "Division of contest" Expected answer: 1 Given answer: 2

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

    Lol

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

    Well, although B and C are a bit tricky, D and E aren't that hard :)

    IMO, D should have been C or maybe even B.

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

:/ I'm bad in CP

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

Problem B had very painful implementation.

Is there some trick in it?

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

    I've just asked other people( after the competition ended). There was a quite simple implementation based on simulation: instead of trying all cases, just try to change a[i] to a[i+1] and and a[i-1], and calculate the improvement.

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

      Yeah, but if we try to simulate it by placing a[i] as a[i+1] or a[i-1], it would go upto $$$O(n^2)$$$.

      And, if we do some precomputation and try to calculate the new result or improvement in $$$O(1)$$$, the implementation goes really difficult.

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

        No. As a[i] belongs only to three groups( i-2 to i, i-1 to i+1, i to i+2), this simulation takes O(1), and the solution using it is O(N)

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

          So, everytime I replace, I need a loop from i-2 to i+2, right?

          Damn, this problem was not too difficult for me then :(. But I messed up.

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

        It wont really, when you change a[i] to a[i+1] for each i you just need to check the defference in peak/valley for the i-1,i and i+1th element

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

I had my worst performance but still definitely a brilliant contest. Thanks for such a great contest. I learnt a lot and I won't repeat these mistakes.

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

Was there an elegant solution to B? I spent 2 hours brainstorming and solved it using prefix, suffix arrays.

For all $$$i$$$ change $$$a_{i}$$$ to $$$a_{i-1}$$$, $$$a_{i+1}$$$, a pretty big value, a pretty small value and count the number of hills and valley. Speed up the counting using prefix and suffix arrays. My implementation was way too ugly.

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

    I first counted total hills and valleys, then for every 1<i<n replace a[i] with a[i-1] and a[i+1]. The counted the min ans for this each 1<i<n.

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

    For each $$$a_i$$$, change it to either $$$a_{i-1}$$$ or $$$a_{i+1}$$$ and recalculate answer.

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

    If you look at the solutions of people that got the AC for example: 103776223 they just check correctly as you said the indexes i-1 and i+1 for all i= 2..n-1 and they make them equal values and then go ahead and see what changed. I also followed the same logic and I was loosing test case 3. I urge them to publish test case 3 so that we find our mistakes. It is a pretty straight forward problem. We can all see that the initial answer can only decrease only by 3 at the most in any test case. I'm going to try and reverse engineer for now and find out what happened in the test case that I'm loosing because it says that my answer was 8 when it should have been 7. I will reverse engineer the test case and publish it here for all the people to find their mistake.

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

      I also failed test case 3, then added additional loops to check $$$a_i = \infty$$$ and $$$a_i = - \infty$$$. Got AC after that.

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

        Look at the submission that I mention in my comment it doesn't use -infinity or +infinity it simply checks the result when ai is the same ai = ai+1 and ai = ai-1

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

    I went all out ad-hoc to solve it. Pretty sure there is an elegant solution out there somewhere.

»
4 years ago, # |
  Vote: I like it -18 Vote: I do not like it

I want my rating back.

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

Can we get the full version of test case 3 for problem B? Thanks a lot.

My thinking which is the same with all the people who got the AC
»
4 years ago, # |
  Vote: I like it +113 Vote: I do not like it

To not keep you waiting, the ratings updated preliminarily. In a few hours, I will remove cheaters and update the ratings again!

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

    Thank you very much we would also appreciate test case 3 on problem B be published soon so I don't have to wait until I manage to reverse engineer it. Thanks!

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

    Hi, have ratings been reupdated yet? If no is there ETA?

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

Finally after 2 and a half years...

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

My solution for problem C failed on test case 17. Can anyone please suggest an easier case on which this solution is failing?

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

guys my contribution is decreasing but i checked every comment i did and there were no downvotes any help!

MikeMirzayanov

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

    Older comments give you less contribution, that's how it works

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

there some moments you want to get wrong answer , a solution you finished writing 2mins after the contest ended is one of those moments. Man just needed 2 more minutes.

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

can anyone explain this part for problem D?

for (int i = 0; i < N; i++)
        for (int x = 0; x <= K; x++)
            coefficients[i] += dp[x][i] * dp[K - x][i];
  • »
    »
    4 years ago, # ^ |
      Vote: I like it +23 Vote: I do not like it

    The idea is for each element a[i], count the number of paths it occurs in. dp[x][i] counts the number of length "x" paths ending at "i". But this isn't quite what we wanted above, so we consider all the paths which have a[i] at the "xth" position in the path. From the dp definition, there are dp[K - x][i] ways to "finish" the path with "a[i]" at the "xth" position, so we multiply the two values together.

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

But in all honesty, a brutal contest. Lucky to have solved 1 problem (late in the contest).

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

My code for problem B got killed by systest, but when I resubmitted the exact same code twice, it passed both times. Is it possible for me to get a rejudge? If not, that's fine :)

Original contest submission (TLE): https://mirror.codeforces.com/contest/1467/submission/103773278

First resubmit (AC): https://mirror.codeforces.com/contest/1467/submission/103811031

Second resubmit (AC): https://mirror.codeforces.com/contest/1467/submission/103811357

Edit: issue has been resolved.

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

The trickier contest than usual.

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

one of the best contest, looking forward to more like these contests

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

SuperFast Results

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

Huh! Superfast rating update.

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

Too much whine just because problem-setters made somewhat tricky questions and didn't give away hints in the samples.

It was unusual but if you ask me, is not it the way it should be?

»
4 years ago, # |
  Vote: I like it +42 Vote: I do not like it
How to determine if a round is good
»
4 years ago, # |
  Vote: I like it +3 Vote: I do not like it

I can't see any penalties for my wrong submissions in this round. Why?

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

I think A, C, D, E were all good quality problems though they bit have been on the harder side. hard != bad problems. B was boring and tedious.

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

    I have to agree B should have allowed quadratic solutions to pass, but the idea behind the main part of the solution is really nice!

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

I found problem E is doable by DSU-on-tree 30 minutes after the contest began, and jump into the honey trap debugging for one hour and a half. It will only cost me 40 minutes if I decided first to do C and D, but it was too tempting for me to solve E first...

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

When I uncomment 4th line i.e when I convert all integer to long long. Why am I getting runtime error on test case 8. Without this conversion i.e. int to long long code is getting accepted.

https://mirror.codeforces.com/contest/1467/submission/103815290

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

    I think that the array gets too big. Try declaring array outside of functions or use vectors.

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

Where are editorials?

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

    It's not been uploaded yet. You can see it on contest problem page when it uploaded.

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

Someone please help me in finding a counterexample for my submission

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

can D solve faster than O(N^2)? I've considered many ways to improve, but couldn't reach any efficient way.

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

    My solution is $$$O(nk + q)$$$. Here's a link to my submission: 103771574. You can also do $$$O(n^3 log k + q)$$$ using matrix exponentiation.

    Edit: Sorry, I didn't realize you meant $$$O(nk)$$$

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

      Sorry for my mistake, I want to know about o(NK). My solution is O(nk + q) too, and considering that it can be more faster or not.

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

        Now that I think about it, you can solve this problem in $$$n^2 log k$$$ using matrix expo and the trick mentioned here. Though in this case it isn't faster, if $$$n \leq 10^3$$$ and $$$k \leq 10^9$$$, this would pass and the intended approach wouldn't. I'm not sure if this would pass with the given constraints though.

        Edit: Nvm, my idea won't work.

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

      hey can you explain your approach? why you multiplied v[i] += dp1[j][i]*dp1[k-j-1][i];

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

One of the Fastest Rating Updates !!!

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

can someone give what are edge cases of Problem B Div 2

»
4 years ago, # |
  Vote: I like it -35 Vote: I do not like it

hello everyone!!!! can you please tell me what's wrong with this solution for the problem B (hills and valleys)?

include<bits/stdc++.h>

using namespace std;

define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

typedef long long ll; const int mod = 1e9 + 7; int main() { IOS; // string s; // cin>>s; //ll n=s.length(); int t; cin>>t;

while(t>0){
ll n;
cin>>n;
ll ar[n];
ll h=0,v=0;
vector<int>q;

    for(int j=0;j<n;j++)
   {
      cin>>ar[j];
   }
   int cnt=0,flag=0,ans=0;
for(int i=1;i<n-1;i++)
{
    if(ar[i]>ar[i-1] && ar[i]>ar[i+1])
    {
        h++;
        flag=1;
    }
    else if(ar[i]<ar[i-1] && ar[i]<ar[i+1])
    {
        v++;
        flag=2;
    }
    if(flag==1 || flag==2)
    {
        cnt++;
        flag=0;
    }
    else
    {
        flag=0;
        ans=max(ans,cnt);
        cnt=0;
    }
}
ans=max(ans,cnt);

// cout<<v<<h<<ans; v+=h; if(ans>=3) v=v-3; else if(ans==2) v=v-2; else if(ans==1) v=v-1; // if(v<0) // v=0; cout<<v<<endl; t--; } return 0; }

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

Does anyone have an idea why this solution doesn't work? https://mirror.codeforces.com/contest/1467/submission/103765146. I think that the problem is not in the idea, but in the implementation, since at the 3rd pretest one result was -27!!! And I have no idea how that could happen, can someone with more c++ knowledge help me?

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

    We need to handle the case n = 1 separately, because your code assumes if i == 0 then i + 1 < n. This got accepted: https://mirror.codeforces.com/contest/1467/submission/103822011

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

      Yeah, thank you. Stupid from me, but to be fair I tried for n = 1 and since it returned correct (cuz c++ undefined behaviour) I did not try to fix it. A good lesson for the future though, for sure.

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

    It was the fact I did not account for n = 1 and since I now use c++ instead of Java it did not say index out of bounds even though I tried for n = 1 (fucking c++ showing right answers anyways LMAO).... That's honestly stupid, I'm sure I could have gotten a very nice point increase. Eh, fuck it.

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

Please can someone provide a counter-case for my submission. My code gave the correct solution for the counter-cases mentioned in the above comments. 103819406

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

If they put C before B, I believe more people will be able to solve it.

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

The contest had very good idea!
But it could gain much more likes if:
1. It was Div 2 contest (it was not), 2. if Testers had think more about contraints: Div2 B is very difficult to pass with scripting language and this forces to optimize only a constant and disables from other interesting solutions with same complexity but with a bit higher constant.

UPD. also, it was boring without hacking on A and B. Why multitests!?

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

I think passing BC needs very careful thinking

Otherwise it will wa many times like me

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

Although I struggled with B, it is hard for me to believe that a simple brute force is enough, I overthought and made it complicated with making shapes/checking valleys and hills.

I found this round pretty interesting. Thanks to setters.

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

    were the shapes M,W,N,flipped N, simple hill and valley?

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

someone knows how to add the date and time of creation of code like tourist does ?

Is it by hand or some script ?