Блог пользователя triple__a

Автор triple__a, история, 4 года назад, По-английски

Hello Codeforces!

I am glad to invite you to my first official round Codeforces Round 630 (Div. 2), which will take place on Mar/31/2020 16:35 (Moscow time) (please note for the unusual starting time) and will be rated for all Division 2 participants.

You will be given 7 tasks and 150 minutes to solve them.

All tasks in this round were prepared by me. Hope that you will enjoy those tasks!

I would like to thank:

To avoid queueforces, we will provide small amount but strong (hope so) pretests for first few tasks. Hope it works!

Score distribution will be announced later.

Good luck and have fun!

UPD1: Score distribution: 500-1000-1250-1250-1750-2250-3000

UPD2: Contest is over, and here is the editorial.

UPD3:

I am sorry that pretests were not as strong as I excepted.

Congratulations to the winners:

div1+div2:

  1. vepifanov

  2. int128.

  3. PinkRabbitAFO

  4. 300iq

  5. nuip

div 2:

  1. int128.

  2. sorry_to_tourist

  3. camilla

  4. jerome_wei

  5. [user: _dawn]

people who were first to solve each task:

A: white_paperdog

B: MagentaCobra

C: okwedook

D: white_paperdog

E: GsjzTle

F: yooooooooo

G: GoGooLi

Lastly, thanks to Handsome2004 for the brilliant hack of E.

  • Проголосовать: нравится
  • +713
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

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

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится -54 Проголосовать: не нравится

    this round suddenly come there was april fool contest and after that div1+div2 after last div3. thanku for the contest. :)

»
4 года назад, # |
  Проголосовать: нравится +43 Проголосовать: не нравится

Welcome everyone to join in $$$⩾w⩽$$$

»
4 года назад, # |
  Проголосовать: нравится -17 Проголосовать: не нравится

hoping to get expert

»
4 года назад, # |
  Проголосовать: нравится +30 Проголосовать: не нравится

I really hope that this H̶o̶p̶e̶ ̶s̶o̶ works!

»
4 года назад, # |
  Проголосовать: нравится +46 Проголосовать: не нравится

Small but strong pretests yey no more queue thank you

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Long time no Chinese Round

»
4 года назад, # |
  Проголосовать: нравится -60 Проголосовать: не нравится

Waited for Div.2 Round long time. :)

»
4 года назад, # |
  Проголосовать: нравится -7 Проголосовать: не нравится

I hope I can get a good score!

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Hope to see my username in blue after this contest. ^_^

»
4 года назад, # |
  Проголосовать: нравится -26 Проголосовать: не нравится

The time is nice for Chinese :P

»
4 года назад, # |
  Проголосовать: нравится +180 Проголосовать: не нравится

I like queueforces. My code feels like schrodingers cat.

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +18 Проголосовать: не нравится

Thanks to all contest writers to make us busy during this lockdown situations. You are doing a great job. STAY SAFE STAY HOME

»
4 года назад, # |
  Проголосовать: нравится +28 Проголосовать: не нравится
Best line
»
4 года назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится

I hope that this contest will increase my rating.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why 150 minutes? Is it hard?

»
4 года назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

how to get started in this contest , can anyone help i am new here

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +8 Проголосовать: не нравится

    go here and click Register Now on Codeforces Round #630 (Div. 2) and be online at the given time.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Just go to contests section and you will find the contest

    You can register in it

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Already did earlier i didn't know where to start

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        the problems are (mostly) ordered in the order of difficulty. So start with A and then B,etc.. But if you are stuck for a long time and can't go anywhere in current question try out another. Also if you have an issue with how to workaround with the UI recommend checking youtube video, there are some which will explain it and also try out a virtual contest to get a practical understanding of it. Best of luck for the contest!!!

»
4 года назад, # |
  Проголосовать: нравится +125 Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится -30 Проголосовать: не нравится

Just curious about the "useful" discussion Nanako and Nezzar took part in.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +73 Проголосовать: не нравится

    Test different kinds of strange solutions, help to structure test datas, give some advice about problems to make difficulty gaps reasonable and so on.

    My work range is not much more than a tester, but my workload is more. I keep communicating with triple__a about these since 2 months ago, and help for much more than 7 problems meanwhile (you know, some problems will be denied when preparing a round), instead of temporarily taking a virtual participation.

    Actually I also tried to give a Problem B when needed, but it was denied. :thinking:

    Don't want to tell much before the contest lol. wish you get a good result in this round.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +10 Проголосовать: не нравится

    Generally testing & discussion of problems. Hope you enjoy the problems triple__a prepared!

»
4 года назад, # |
Rev. 2   Проголосовать: нравится -43 Проголосовать: не нравится

Due to Quarantine registration will exceed 20K for sure. Thanks codeforces for arranging contests, the only partner in this quarantine :)) #GOCORONA #STAYSAFE #HAPPYCODING.

»
4 года назад, # |
Rev. 3   Проголосовать: нравится -8 Проголосовать: не нравится

how rating of expert contestents change in last div 3 round? sorry, I didn't notice.they fixed this.

»
4 года назад, # |
  Проголосовать: нравится +27 Проголосовать: не нравится

I am glad to be the contributor to this round.But due to my weak ability I can't test hard problems :-(

Wish you guys like this round of Div2!

»
4 года назад, # |
  Проголосовать: нравится -11 Проголосовать: не нравится
7 Problems !!
»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

150 minutes...oh yeah!!...I got no work to do in this quarantine anyway.

»
4 года назад, # |
  Проголосовать: нравится +30 Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Nice rating graph triple__a

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I receive the message from admin and surprised

The allowed programming languages are C/C++, Pascal, Perl, Java, C#, Python (2 and 3), Ruby, PHP, Haskell, Scala, OCaml, D, Go, JavaScript and Kotlin.

Is Rust banned? I can't see the name on the list.

Below is the one from the last educational and surely see Rust before Kotlin.

The allowed programming languages are C/C++, Pascal, Java, C#, Python, Ruby, Perl, PHP, Haskell, Scala, OCaml, Go, D, JavaScript, Rust and Kotlin.

»
4 года назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

I need triple(+7) to become Candidate .. I hope i will earn them !

»
4 года назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

****I'm really honored to take part in this test**** ****Good luck everyone!****

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Thanks all of the members of this contest to prepare another good contest hopefully

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

First time participating in a live contest. Y'all got any pointers ?

»
4 года назад, # |
  Проголосовать: нравится -23 Проголосовать: не нравится

Alas! I can't solve solve problem B/C. I just can solve problem A.

»
4 года назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

Corona has definitely increased the participation in the recent contests. Thank you MikeMirzayanov for providing a great platform and, Thanks to problem setters too, for providing set of some amazing problems.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +56 Проголосовать: не нравится

B worth 1000 and D worth 1250 points? Quite weird, I think you could have saved one problem (C or D) for a future contest.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Maybe C and D are subtasks? Who knows ))

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +11 Проголосовать: не нравится

      The author said that there are no subtasks

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        My bad. Perhaps it is because of the fact that all the tasks are made of the same author, so it would be better to gather them together. Wish we will experience a great round with full of new challenging problems!

»
4 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Best of luck guys !!!

»
4 года назад, # |
  Проголосовать: нравится -28 Проголосовать: не нравится

My request to admin to conduct more contests while this lockdown period. Thanks

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +33 Проголосовать: не нравится

    They need time to prepare good quality rounds. Holding more rounds will definitely affect their quality.

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

      Yeah, But by taking help of good programmer may help to conduct. Code forces is known for its good quality rounds. Yeah.Quality of rounds should not be compromised. :)

»
4 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

After seeing the score for question c and d. Excited to see which one will be easy one.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Guess, Which one will get more accepted, C or D?

»
4 года назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

We need more such contests in this quarantine period. Another Reason to stay at home.

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +11 Проголосовать: не нравится

.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

HackForces?

»
4 года назад, # |
  Проголосовать: нравится +9 Проголосовать: не нравится

Small number of pretests is somehow already making me feel uncomfortable, I just hope it works well.

BTW, I am curious how hard it is for Codeforces to scale to the increasing number of users, I think registrations are about thrice the amount I used to see in last year, so can't just CF add some more processors(so that now they get 3x processors) or get something like thread ripper to judge systems so that queues are gone. I expect the number of submissions to be linear to the number of participants.

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

More than 20k people! this will be fun!! :D

»
4 года назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

Quick Check:- This is first contest designed by triple__a

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

WOOOOO I am very expect to join the contest,hope for a good game experience and everybody will get good rating improving o-o

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Huge participation indicates more people performing home quarantine.

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +8 Проголосовать: не нравится

CF gonna fall down

»
4 года назад, # |
  Проголосовать: нравится +27 Проголосовать: не нравится

problems are so fricking complicated I dont mean it is hard it is complicated fricking contest

»
4 года назад, # |
  Проголосовать: нравится +54 Проголосовать: не нравится

I guess it's just my taste but A was quite disgusting

»
4 года назад, # |
  Проголосовать: нравится -84 Проголосовать: не нравится

stop setting problems.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +19 Проголосовать: не нравится

    stop complaining. The service provided here is free, you are not paying anyone and why does it matter to unrated acc.

»
4 года назад, # |
  Проголосовать: нравится -27 Проголосовать: не нравится

let's make a round which is neither queueforces nor readforces next time!

»
4 года назад, # |
Rev. 2   Проголосовать: нравится -27 Проголосовать: не нравится
Комментарий удален по причине нарушения правил Codeforces
»
4 года назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Quality with Difficulty

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Really all problem are look like more tougher than usual contest

»
4 года назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

I feel like 2:30H is too much for a cf contest.

»
4 года назад, # |
  Проголосовать: нравится -9 Проголосовать: не нравится

Chinese Round is too hard for me.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I am glad that at today's round there were no queues and exits from the profile, thank you very much!

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Praying God for not failing in system test.

»
4 года назад, # |
  Проголосовать: нравится +40 Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится +14 Проголосовать: не нравится

For everyone that had WA#3 on E: Every board is valid for odd N and odd M... Took me more than an hour to notice it :D

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +21 Проголосовать: не нравится

    It's also the first test on which not changing mod from 1e9 + 7 fails :P

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Exactly the same problem. Fortunately noticed it in the last 5 minutes, and only needed 1 line change in code to solve it :D

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

How to solve G?

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится
  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Could you explain how you approached C

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      You can observe that the string which is the period has to be palindromic as well

      Just greedily choose the maximal frequency of each letter and drop from n the sum of maximal frequences

  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    What is the minimum size of the matrix which could be formed in que D?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      You need at least two lines to make some variation(for n = 1 the DP algorithm is optimal)

      You also need at least two columns to generate the variation, but we need one more column to actually translate the new result, so 2x3 is min size(or 3x2, it's the same thing)

»
4 года назад, # |
  Проголосовать: нравится +25 Проголосовать: не нравится

I don't know how it was for you guys, but for me it was a hard round. :\

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +4 Проголосовать: не нравится

    So hard :с

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I am excited to see the editorial now :D

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      It is true that the problems were hard to comprehend at first. But I think it's only A and B that hindered the progress of most participants. While the problem A was quite obnoxious, B was not as bad. I personally think they should have swapped B and C.

»
4 года назад, # |
  Проголосовать: нравится +46 Проголосовать: не нравится

Hardest ever A .

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    I think D was hard. It made me really sit and think.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится -29 Проголосовать: не нравится

      D was really Trivial.

      But it took me an hour because I was thinking in the wrong side

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится +17 Проголосовать: не нравится

        D is trivial then and only then you already know, how to solve it

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится 0 Проголосовать: не нравится

          Lmao the example case literally gave you the working grid. If it weren't for the example case it would've taken me much longer.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    I solved B & C but not A. actually it seems so lengthy for me I didn't wanted to give time for this. :(

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      What is your approach for solving B?

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

        B was easy I just generated all primes within 1000. and for each prime p (from least >=2) I traverse the array and i checked if(arr[i]%p==0) I assigned same color to these because gcd will be >=2. and you can see you can't have composite number n<=1000 such that n= pi*pj & pi,pj both > 11st prime

»
4 года назад, # |
  Проголосовать: нравится +80 Проголосовать: не нравится

When you realize B solution only need first 11 primes

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

had a bad experience

»
4 года назад, # |
  Проголосовать: нравится +41 Проголосовать: не нравится

E is one of the most elegant problems I've seen so far :o

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Can you tell your thought process for it?

    • »
      »
      »
      4 года назад, # ^ |
      Rev. 2   Проголосовать: нравится +30 Проголосовать: не нравится

      First, note that you can replace all numbers with their values mod 2. Indeed, take m = max(a_ij), and then add 2 to each cell until they become either m or m + 1. The parity will not change. Then the first operation in the statement is useless, and the second one is simply inversion mod 2 (0 -> 1, 1 -> 0). In fact you can swap numbers in adjacent cells. This means you can move 1's arbitrary around the board. Also, if you have two 1's in adjacent cells, you can turn them into 0's by adding 1 to each.

      So the problem reduces to the following: you have nxm board with 0's everywhere apart from the corner cell, where it stands 1 or 0 (depending on the parity of the initial sum in all cells). Then 2 cases:

      1) n*m is odd
      2) n*m is even

      So the answer is the following: if n*m is odd, it is always possible with any a_ij. If n*m is even, it is possible if the sum of all a_ij is even. Now, let's solve the problem :)

      1) n*m is odd
      2) n*m is even

      All what is left is to calculate n*m powers — this you can do by fast power calculation, and fact that $$$x^{nm} = ({x^n})^m$$$.

»
4 года назад, # |
  Проголосовать: нравится +19 Проголосовать: не нравится

Can someone please help, how to calculate the number of correct boards in E when n * m is even.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится -10 Проголосовать: не нравится

    if (r-l) is odd $$$\frac{(r-l+1)^{nm}}{2}$$$

    else $$$\frac{(r-l+1)^{nm}}{2}+1$$$

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +3 Проголосовать: не нравится

      How did you get that formula?

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        In odd case, it is number of all possible grids. In even case, it is same but divided by 2, because we only need ones whose sum of initial heights is even

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      It should be $$$\frac{(r-l+1)^{nm}+1}{2}$$$ instead of $$$\frac{(r-l+1)^{nm}}{2}+1$$$

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Can you tell how you get the formula in brief ?

        • »
          »
          »
          »
          »
          4 года назад, # ^ |
          Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

          If $$$nm$$$ is odd, all grids are valid. One way to prove it is coloring the grid with a checkerboard pattern (let's assume that the cell in the upper left corner is black) and noticing that you can fill the grid with $$$\frac{nm+1}{2}$$$ dominoes of size $$$2 \times 1$$$ in such a way that each cell is covered and a white cell is covered twice. Using the operation 1, you can increase the value of any white cell by 2 and the value of the other cells by 1 (let's call it operation 3). So, a possible strategy to win is to make the height of all black cells the same, and then use the operation 3 to fix the height of the white cells.

          On the other hand, if $$$nm$$$ is even you can win if and only if the parity of the sums of the heights in the white and in the black cells is the same.
          First, let's calculate in how many ways you can fill k cells with numbers in the range $$$[l, r]$$$ and even/odd sum ($$$dp_{even}[k], dp_{odd}[k]$$$). You can get these values by the following relations:
          $$$dp_{even}[k] = dp_{even}[k - 1] * dp_{even}[1] + dp_{odd}[k - 1] * dp_{odd}[1]$$$
          $$$dp_{odd}[k] = dp_{even}[k - 1] * dp_{odd}[1] + dp_{odd}[k - 1] * dp_{even}[1]$$$
          The relations can be obtained by fixing the parity of the sum of the first $$$k - 1$$$ cells.
          If $$$r - l$$$ is even, there are $$$\frac{r - l}{2}$$$ even numbers and $$$\frac{r - l}{2}$$$ odd numbers in the range, so $$$dp_{even}[1] = dp_{odd}[1]$$$ and $$$dp_{even}[k] = dp_{odd}[k] = \frac{(r - l + 1)^k}{2}$$$.
          Then let's fill all the grid ($$$\frac{nm}{2}$$$ white cells and $$$\frac{nm}{2}$$$ black cells). The result is $$$dp_{even}[\frac{nm}{2}] * dp_{even}[\frac{nm}{2}] + dp_{odd}[\frac{nm}{2}] * dp_{odd}[\frac{nm}{2}] = \frac{(r - l + 1)^{nm}}{2}$$$.

          If $$$r - l$$$ is odd, you can prove by induction that $$$dp_{even}[k] - dp_{odd}[k] = \pm 1$$$. Using some algebra, you can get the result $$$\frac{(r - l + 1)^{nm} + 1}{2}$$$.

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

this is my first time to take part in a real contest. But... I couldn't solve a single task lol

»
4 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

Loved D ques.

It was really trivial if you know the basics of BitWise Operations.

»
4 года назад, # |
  Проголосовать: нравится +22 Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

for E, the idea I had in mind was the total count of odd numbers in the grid must be even, then with finite no of moves we can get all numbers with same parity. can someone say where this is going wrong?

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Please share soln of B !!!!

  • »
    »
    4 года назад, # ^ |
    Rev. 3   Проголосовать: нравится +3 Проголосовать: не нравится

    Hint : all number given as input must have a prime factor in 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 because if all factors are above 31 then number will go beyond 1000 .

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    The concept is based on Sieve of Eratosthenes, that is crossing out multiples of each prime number, and while crossing out multiples of primes, mark them with colours.

    • p, p*2, p*3, ... , p*n (You can see gcd will be at least p-prime number.)

    And, according to constraints given you can just colour all the numbers with the first 11 prime numbers.

    Submission

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      sieve is not really needed here just make a set of smallest prime divisor of all numbers it will(number of sets) be less than equal to 11.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      I did the same, got wrong answer somehow. Seems correct to me (Works on the testcases given)

      https://codeforces.com/contest/1332/submission/74968519

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        Your output is not correct. It outputs a total number of 10, which means you can only use color from 1 to 10. Your solution actually uses color 11, but not 9.

        You are missing one step here, iterate over your color array and do a mapping to make each color used within the range of [1, total unique color count].

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Since they said Answer will always exist, simply brute over all multiples of numbers from 2 to 1000 present in array which are univisited and assign them color.

»
4 года назад, # |
  Проголосовать: нравится +15 Проголосовать: не нравится

Shortest solution to a D problem ever. Loved the simplicity ;)

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +3 Проголосовать: не нравится

I'm failed at D at the last minute because number larger rr than >300000 if only i had read the checker logs :(

»
4 года назад, # |
  Проголосовать: нравится +41 Проголосовать: не нравится

-what if we use 100% of the brain?

=write a hard contest so many participants will hardly solve A and dont solve any other questions and leave the contest so the traffic on the server wont be huge like the last contests

»
4 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

D sample test itself is a gigantic hint.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    That is very true!Guess what xD? I copied the second sample output and modified it a little bit and done, accepted!

»
4 года назад, # |
Rev. 2   Проголосовать: нравится +5 Проголосовать: не нравится

For G i did this following observations:
1. It's obvious that answer is 3 or 4
2. Let's suppose we have answer with 4 elements and the indexes are i1,i2,i3,i4. if there exists a solution, that means that there is a solution where i1 and i2 are adjacent indexes + i3 and i4 are adjacent indexes too.
3. So from point 2 , we conclude that we need to find i1 & i3 indexes, such that a[i1]>a[i1+1], a[i3]>a[i3+1] , a[i3]>a[i1] and a[i3+1]>a[i1+1] (or vice versa for a[i1]<a[i1+1] and a[i3]<a[i3+1])
Is the solution based on developing this idea or I am going the wrong direction?

»
4 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

This Div2 was having more puzzle problems, I guess!

»
4 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

A,B,C Indexfiddlingforces.

However given that lengthy statements it was still fun to participate. For me B was much harder than C. Felt like being testet on how much index-one-off-errors can one avoid.

»
4 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Me RN

»
4 года назад, # |
  Проголосовать: нравится +13 Проголосовать: не нравится

First of all kudos and thanks to codeforces for handling high participation so nicely.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Thanks for the contest. Wish problem-setters have good days <3

By the way, how to solve E guys ? :(

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone help me , what i am missing in my logic for question C (k- string)??

Logic : I deduced condition that all of given condition will be satisfied if we try to make an string of length K which is a palidrome. and replace it in all n position (i%k th place).

So first , i stored max count of the variable occuring at a position i(1<=i<=k) ; i stored and made a char array for so(max var);

then afterwards in order to make those k char a palidrome ,i checked from both side to find the optimal character for each pos,

at last i ran loop on string and counted the number of pos (pos%k) ,i need to change ,in order to make it combination of k legth optimal string.

Code

Also , my logic gave incorrect ans on 4th tc (i got 17 but ans was 16)

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    One way to solve it to group positions which must have same characters to satisfy the rules. Then, foreach such group contribute $$$ans+=countPositions-maxFreqInGroup$$$ of that group.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      But how this formula is going to ensure that resulting string will be a Palidrome??

      • »
        »
        »
        »
        4 года назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        You need to choose the groups of positions right.

        That is, every segment of k chars must be a palindrome, too. So within each segment of k chars is is that $$$s[i]==s[k-1-i]$$$ and all segments are equal. So there are $$$(k+1)/2$$$ groups of positions.

        We need to find the min count of operations to make all chars of one group same, for all groups. If they are same, the whole string is a palindrome.

  • »
    »
    4 года назад, # ^ |
    Rev. 3   Проголосовать: нравится +4 Проголосовать: не нравится

    I also had this problem in my code. But I corrected it after realizing that we have to consider both positions period and palindromic as they all should have same characters.

    As you are considering all characters frequency which are at at pos = i % k and you are selecting max from that for pos = i % k.

    But you also have to consider k - pos - 1 characters for pos = i % k.

    Reason is we have to consider frequency of all characters which can come at pos = i % k and they can be due to period positions and due to palindromic positions.

    My Submission 75017302

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

Am I the only one who did problem C. using a simple DFS with connected components? Felt like an overkill...

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Wait DFS how?

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +1 Проголосовать: не нравится

      Build a graph as follows: — each node represents a position in the array — an edge (u,v) exists if and only if u and v must have the same letter

      You can build the edges from the palindromic and period conditions.

      Then, all the vertices in a connected component must have the same letter. And in order to be optimal, we choose the letter that is the most frequent in that component. Then we repeat this for all components.

      Connected components are usually handled with a DFS.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I did that too. I knew there would be an easier way but I just went with the connected components approach and it took me a lot of time.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Can you briefly illustrate your approach?

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится

        lets take that example: 6 2 abaaba

        transform it into: 121212 To make it palindrome, the last number and the first number must be the same. You will connect all the components together and use DFS to know which one belongs to which and then get the most repetitive character from all the numbered ones and then subtract it by the total characters that you counted in the set. It is like DSU but DFS is easier and faster to implement than DSU. It is clearly shown in that example that 1 and 2 are connected. So all characters must be the same. But that example:

        6 3 abaaba

        Transformation: 123123

        It is clearly shown that 1 and 3 components are connected. But 2 is not connected. So all 1's and 3's characters' must be the same. But 2 is independent.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I did it as well

  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    I solved C using DSU (managing connected components). It was the first (and only) approach that came to my mind. I thought it will be the most intuitive approach (for others as well).

    Here's my solution: https://codeforces.com/contest/1332/submission/74985309.

»
4 года назад, # |
Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

Solution for E: Let total odd numbers in the range be odd, and total even numbers in the range be even. Let tot=n*m

If tot is odd, then answer is power(even+odd,tot). else the answer is (power(even-odd,tot)+power(even+odd,tot))/2

IS THIS APPROACH CORRECT?

  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    The second formula should just be (power(even+odd,tot)+1)/2. EDIT: Nevermind, I think this is equivalent to what you said, you are correct.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

B has taken much time because I cannot understand the meaning of the range of $$$m$$$ at first.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why Bob is incorrect in question D, i think his algo is correct for maximum??

»
4 года назад, # |
  Проголосовать: нравится -75 Проголосовать: не нравится

MikeMirzayanov

My Code is giving right answer for the given test cases of problem -c while running in IDE geeksforgeeks and ide codechef Then I submit it on codeforces..bt it gives wa for the 3rd case of given pretest..It's really frustrating!! Please check once my code..tell why this is happening

include<bits/stdc++.h>

using namespace std;

define ll long long

define ld long double

define pb push_back

define pi pair<int,int>

define pl pair<ll,ll>

int main() { ll t; cin>>t; while(t--) { ll n,k,i,mx,tot=0,j,f; cin>>n>>k; ll fr[27]={0}; string s; cin>>s; for(i=0;i<k/2;i++) { for(j=0;j<26;j++) fr[j]=0; f=0; for(j=i;j<n;j=j+k) { fr[s[j+k-1]-'a']++;

fr[s[j]-'a']++;
        }



        mx=*max_element(fr,fr+26);
        for(j=0;j<26;j++)
        {
           // cout<<fr[j]<<endl;
            tot+=fr[j];
        }
       // cout<<tot<<" "<<mx<<endl;
        tot=tot-mx;
        //cout<<tot<<endl;
    }
    if(k%2==0)
    {
        cout<<tot<<endl;
    }
    else
    {
    for(i=0;i<26;i++)
    fr[i]=0;

        for(i=k/2+1;i<n;i=i+k)
        {
            fr[s[i]-'a']++;
        }
        mx=*max_element(fr,fr+26);
        for(i=0;i<26;i++)
        {
            tot+=fr[i];
        }
        tot=tot-mx;


    cout<<tot<<endl;
    }
}
return 0;

}

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

For problem B

Input:

23

437 519 865 808 909 391 194 291 237 395 323 365 511 497 781 737 871 559 731 697 779 841 961

My output is

10

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

And I got this message: wrong answer violates gcd constraint.

Can anyone help explain? I don't really understand the conditions of this problem

»
4 года назад, # |
Rev. 2   Проголосовать: нравится -51 Проголосовать: не нравится

it was very good contest

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Can someone tell me why I get TLE: https://codeforces.com/contest/1332/submission/74951923 I genuinely don't know.

»
4 года назад, # |
  Проголосовать: нравится -41 Проголосовать: не нравится

My quick review:

A — classic shitty A with many cases

B — too long statement for such an easy task

C — good task but too simple for C

D — awful constructive

E — classic «try and guess» combinatorics

F — pretty standard dp (counting again)

G — good task

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In E, I sincerely thought that answer height had to be between L and R also and was losing my mind for an hour.

»
4 года назад, # |
  Проголосовать: нравится -97 Проголосовать: не нравится

I just downvoted your contest.

FAQ What does this mean? The amount of contribution (points) on your comment and codeforces account has decreased by one.

Why did you do this? There are several reasons I may deem a comment to be unworthy of positive contribution. These include, but are not limited to:

Rudeness towards me,

Making bad contest,

Sarcasm not correctly flagged with italic font.

Am I banned from the Codeforces? No — not yet. But you should refrain from making contests like this in the future. Otherwise I will be forced to issue an additional downvote, which may put your commenting and posting privileges in jeopardy.

I don't believe my comment deserved a downvote. Can you un-downvote it? Sure, mistakes happen. But only in exceedingly rare circumstances will I undo a downvote. If you would like to issue an appeal, shoot me a private message explaining what I got wrong. I tend to respond to Codeforces PMs within several minutes. Do note, however, that over 99.9% of downvote appeals are rejected, and yours is likely no exception.

How can I prevent this from happening in the future? Accept the downvote and move on. But learn from this mistake: your behavior will not be tolerated on CodeForces.com. I will continue to issue downvotes until you improve your conduct. Remember: Codeforces is privilege, not a right.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +48 Проголосовать: не нравится

    If you want to criticize someone just say what you don't like, there's no need to be snarky with this whole 'legal downvote' act or whatever this is supposed to be.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I really liked the problems :)

I thought they were balanced; considering the score distribution of course.

I think the reason some found them to be unbalanced is that they were kind of unusual. Especially B D which were not like most B Ds. If you ask me though, that's a very good thing.(some saw A to be too tricky and long though, which is kinda true)

The round was smooth enough to be a success considering how many registered.

Good job, you should be proud!

»
4 года назад, # |
  Проголосовать: нравится +28 Проголосовать: не нравится

Sample test 2 for D gave it away

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

A really Good Contest. Handled 23k Participants with almost negligible waiting queue and still fairly enough strong pretests.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Super Fast editorial

»
4 года назад, # |
  Проголосовать: нравится +12 Проголосовать: не нравится

I figured out why many people(including me) got wa on test 57 in E)
it was because of %(mod-1)

x^y≡x^(y%(p-1))mod p
but there is a condition that x needs to be coprime to p
the following test case was a corner case- 998244352 2 1 998244353

the sad thing is that %(mod-1) wasn't even needed. I wish this test case was in pre-tests

»
4 года назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Why my first submission to problem B get AC ? The array "to" is out of bounds 75000215

  • »
    »
    4 года назад, # ^ |
    Rev. 2   Проголосовать: нравится +7 Проголосовать: не нравится

    It's an array, so you have undefined behavior without errors. It's not affected to your solution, because you aren't using values from to[11-13], but you're only assigning it.

    • »
      »
      »
      4 года назад, # ^ |
        Проголосовать: нравится +8 Проголосовать: не нравится

      But in some cases col[i] use all number from 1 to 11,and to[11] is also used

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 2   Проголосовать: нравится +9 Проголосовать: не нравится

        Undefined behavior is undefined...(You were lucky to have free memory after to array in each test, so you could use it. I'm obviously not expert in c++, but once I saw a similar example)

      • »
        »
        »
        »
        4 года назад, # ^ |
        Rev. 3   Проголосовать: нравится +8 Проголосовать: не нравится

        On my machine it works, on cf's custom test too, but at the same time it is ub:

        int arr[3] = {1,2,3};
        arr[3] = 4;
        cout << arr[3]; //output is 4
        
        • »
          »
          »
          »
          »
          4 года назад, # ^ |
            Проголосовать: нравится +9 Проголосовать: не нравится

          Okay I got it ,anyway I should avoid such errors,thank you very much

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hi, can someone help me figure out what was wrong with my submission for problem B?

https://codeforces.com/contest/1332/submission/74968519

I am a beginner and I am really confused as I implemented a very similar solution to the problem as is given in the editorial.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    Re-read the "Output" part of problem statement and compare it with your output of the 3rd subtest.

»
4 года назад, # |
  Проголосовать: нравится +76 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится +11 Проголосовать: не нравится

Am I the only one who started solving D with XOR instead of AND (and only realized the mistake after getting WA2)?..

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Was A tougher than normal today or was it just me?

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +6 Проголосовать: не нравится

    It was the worst A in my life:/

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +9 Проголосовать: не нравится

    my theory is they made it a bit implementation-heavy to avoid the initial congestion of 20000 submissions in the first 2 minutes :p

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    I think no.. One simple solution is to print 'W' at last cell i.e at (n,m) and keep all cell 'B'..It will be quite tough if try in other way

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

weak testcases and the queue wasn't full like last div3

»
4 года назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Math forces :/

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Nice contest.

A was somewhat harder than usual Div2 contests (BTW, thanks for including the third testcase in the sample — I completely missed that possibility), but I have seen far worse.

B and C were good problems — moderate implementation. I felt D was a bit more difficult to think of, so D should have been worth more points than C. D should probably be worth 1500 points, and E at least 2000 points.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Was it really necessary to make the bounds up to 2 * 10 ^ 5 instead of 10 ^ 5, I felt this was unnecessary. I am a bit biased because this was the cause of my FST on problem C.

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

What does "violates gcd constrain" means?

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Minus A
I really enjoyed the problems from this round

And the definitions of left, right, down and up in A were really weird

  • exactly a steps L: from (u, v) to (u − 1, v);
  • exactly b steps R: from (u, v) to (u + 1, v);
  • exactly c steps D: from (u, v) to (u, v − 1);
  • exactly d steps U: from (u, v) to (u, v + 1);

This doesn't feel right at all!
I feel left and down should be swapped same for right and up

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

triple__a, respect.

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

You should post the top scorers as well as the 1st solves for each problem. That would be cool

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Thank you for the contest triple__a, I really enjoyed it :) Particularly problem D, which I managed to get in the last 2 minutes (luckily), which was really fun to do!

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Why do we need to consider both cnt[i%k][j] and cnt[k-i%k-1][j] in question C?

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

OK!

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

does memset work slow?

problem c gives TLE using memset [submission:https://codeforces.com/contest/1332/submission/74982492]

with vector got AC [submission:https://codeforces.com/contest/1332/submission/74983633]

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

    Memset is wildly fast. The issue with your submission is that you memset the entire array (of size 5.2 million) for each of up to 100000 test cases. This is $$$5.2 \cdot 10^{11}$$$ operations, which is way too many. Manually filling the array with zeroes up to $$$n$$$ or $$$k$$$, or using vectors in your case, makes your runtime on the order of $$$\sum n$$$ instead of $$$T \cdot 5.2 \cdot 10^6$$$.

»
4 года назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

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

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hey! I am very beginner to competitive coding. may anyone suggest any lead from where i should start?

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Hey guys, I made a video tutorial for problem F which, btw I really enjoyed solving! https://www.youtube.com/watch?v=oEPtZLUG4iQ