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

Автор shaanknight, история, 6 лет назад, По-английски

Hello Codeforces!

We are thrilled to invite you to CodeCraft-20 (Div. 2), which is to take place on Mar/04/2020 17:35 (Moscow time). The contest is rated for all participants with ratings under 2100.

The contest comes under the wing of Threads '20, the annual technical fest, a part of Felicity, IIIT Hyderabad .

Participants will be asked to solve 6 problems in 2 hours . Scoring will be announced just before the contest .

The problems were created by gaurav172, lazyneuron, preet_t and shaanknight .

We want to thank all the people for making this contest possible .

Wish you luck and hope you like the problems !!

UPD 1:

Score-Distribution

500-1000-1500-1750-2250-2500

UPD 2:

Congratulations to the winners of the round.

Div 1

  1. tmwilliamlin168
  2. 244mhq
  3. natsugiri
  4. Golovanov399
  5. Egor

Div 2

  1. Afterglow
  2. Zetro
  3. I-Love-Islam
  4. DraqonLore
  5. ix35

UPD 3:

Editorial

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

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

Please make strong pretests this time.

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

    Is it rated?

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

    IMO pretests are sometimes too strong these days (especially with multitest), rendering hacking virtually impossible. I'd actually prefer to see a contest where it can pay off to search the room for hacks. As for now, sadly, this feature, once a funny part of Codeforces contests, is becoming less and less usable.

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

      Hacking was never funny nor was it usable, it was always just a swarm of edge cases on div2 B and a rush to grab hacks among the participants in the room. It's unfair and giving points for hacks should be disabled.

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

      It is true that the ratio of system failure has decreased on average compared to a few years ago. However, we must consider that the number of participants has greatly soared, which means that hacks have become more effective.

      I do not claim that the points from hacks is improper. Hacks are fun! Nevertheless, severely weak pretests might cause disruptive scoreboards, since hacking structure usually follows a-few-winner-takes-it-all.

      The main source of points should be the accepted solutions, not the hacks.

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

Is preet_t's problem really pretty?

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

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

Why div2 only?

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

Codecraft-17 : Hackforces

Codecraft-18 : More Hackforces

CodeCraft-19 : Terrible Hackforces

There was room like this :

Codecraft-20 : ??

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

2 years ago CodeCraft was combined round! Why did it downgrade to div2 only?

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

make strong pretests so that we do not feel bad.hoping a nice contest and thanks to codeforces.

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

Indian round cool... Hope to learn new things...

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

Excited for this contest!

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

Interesting problems with strong pretests

hoping for a good round and rating increas

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

Indian Round after long time :)

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

Click the "Felicity, IIIT Hyderabad" link in this announcement above.

And then, in this website, click the icon located at the top-right corner of the page.

And then......

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

IIIT Hyderabad is diamond of india in coding.my Respect.

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

Loaded for rocket launch.

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

OMG,i am afraid of attending this round now

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

Codeforces $$$\times$$$
Hackforces $$$\surd$$$

stronger pretests this time pls

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -52 Проголосовать: не нравится

This contest won't be rated bc of bad pretests :P

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

I hope the round won't be like the HackCraft round before...
Also the order of the problems...

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

Anybody explain please, difference between rated and unrated contest? Thanks in advance.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

I hope CodeCraft is as good as Minecraft

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

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

Oh my gosh another codeforeces round, It's so exciting, can't wait but honestly when will be round for slower and disabled contestants? (where all the problems are easy and time is not so decisive factor, and you really guys are reading all that math equations so easly?) Anyway good luck guys!

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

Deleted

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

Hope for no accidents...Hacking is too terrible!!! QAQ

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

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

I am (and not only I am, honestly) participant "in competition" with rating greater than 2099 now. Should I re-register to participate out of competition?

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

Text of tasks in English?

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

I will not able to participate in this contest due to my exams ... feels so bad

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

![ ]()

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

thanks for one more good mathforces round!!!

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

Is C really this tough! or I'm the stupid one!!

Leaving this round 35mins before yay!!! XDXD

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -51 Проголосовать: не нравится

I dont know if the difficulty of problem C is proper for div.2 C . Seemingly it requires some math knowledge that only students major in Maths learn. And it is my 1st time to fail at div.2 C after I became 'Master'.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -39 Проголосовать: не нравится

Thank you very much for proving once again why Indians should never be trusted with contests in a prestigious platform like this.

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

    Like how the hell does nationality come in? If it's a bad contest, it's a bad contest. A mathy one, then it's a mathy one. Blame the problem setters. Downvote the announcement. But why the hell are you pulling their nationality into the picture??

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

AB-Forces

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

AB Forces!

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

Weird bug — My handle changed to swust5120175180 in the standings!?

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

How to solve C?

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

How to solve E ? I had following idea — Sort by 'a' and then do dp[i][mask] = maximum score till i'th index such that 'mask' position of players are selected. Add it to audience if possible. This gave WA-16.

Edit — Caught the error.

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

Whats pretest 7 in C problem?

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

Any hints on how to approach C? Hitting TLE on pretest 7.

I am not able to simplify the question further. I can't find the relation between GCD(, ..., ) = 1 and prime p. Does prime p have any significance in the logic or solution behind this question? Also, does GCD() = 1 has any importance in the solution?

p.s. Not able to solve Div2C after a long, long time. It hit me so hard!

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

Can someone tell me why my code in B times out?

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

How to solve E? I couldn't deal with the necessity of keeping sets/vectors of all elements chosen as audience while trying to take i-th citizen as a member of the audience.

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

I googled for C 2 minutes before ending and got AC. (https://imgur.com/a/NXx553s)

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

C even did not understand the question. It is a math riddle, I am sure there are people happy with that. Not me.

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

Problem D: go in two phases: the first phase make the connected component of sink point to the sink. In the second phase, do the similar with {-1,-1}'s, except make a "sink" be the circuit of size 2.

Is this a correct strategy?

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

    T-shaped tetris is possible!! for example -
    RDL
    XUX
    that was I missing.

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

      Good point, edited. It seems that we only need eventually periodic.

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

      I think you can connect 2 adjacent cells whenever you can (so that they form a loop) and if some single cells remain, you can connect them to an existing adjacent loop. In such a way, as soon as it starts from that cell, on the first move it will go to the loop and after that, it will run infinitely!

      For example, if we had something like that:

      ...

      -.- (where — are occupied cells and . are infinite ones)

      You can connect the (1, 1) and (1, 2) squares to form a loop and the remaining could be directed on this loop, like this:

      LRL

      -U-

      We are 100% certain that this method will always work!

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

    For any {-1,-1}, it's enough to point it to a neighouring {-1,-1}. If there is none, no solution exists.

    Unfortunately, I got TLE because of an extremely dumb mistake (re-initialising the NxN visit matrix every iteration...), but I think this should work.

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

How to solve E?

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

Can somebody tell a counter case for my code of D. It failed at pretest 9. https://mirror.codeforces.com/contest/1316/submission/72455182

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

Is it possible to solve E faster than $$$O(p^2\cdot 2^p\cdot n)$$$?

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

So bad,My fft don't solve div2 C!!! I think it maybe overflow

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

LOL, B was much harder than it should've been, I solved E faster than B! XD

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

why was there a D just why

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

C was actually quite interesting to me. If anyone still doesn't know how to solve, it is sufficient to take the first coefficient in both A and B that isn't divisible by $$$P$$$ and output the sum of their powers, call it $$$X$$$ (this is guaranteed to exists because of the gcd condition). To understand why this works, consider the summations of coefficients mod p. For every term in the summation besides the coefficients that we have taken, at least one term in the product will be divisible by $$$P$$$, thus all terms that contribute to the $$$X th$$$ power will evaluate to 0 except for the two that we have chosen which cannot be divisible by $$$P$$$, thus the coefficient in the multiplied polynomial will not be zero.

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

To me it's ABodeforces...

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

Can anyone give me a counter example to my code on D? https://ideone.com/OgTmuL What I'm doing is: find all 'X's and branch off them by reversing the given instructions For the (-1, -1)'s, I group them in groups of two adjacent if possible and make them "look" at each other (For example: RL) Also how to solve B?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

Just why ? Why give such braindead heavy implementing problem like D.

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

How to solve D?

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

what a shitty day, IRS scamming at its finest

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

How to solve F?

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

I don't believe I'm asking this, how to solve B?

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

In problem C, could somebody tell me if multiplying polynomials using divide and conquer method would get AC? I'm not sure of the complexity of this algo, but I couldn't implement it anyway...

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

In B, O(n^2) solution will have 10^9 operations while time limit is 1 seconds only, why it is not giving tle.?

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

I don't know why people are complaining so much about C being mathforces.
I think it just required little bit of observation and a basic fact that: k*p + a is never divisible by p.
Where, k is some integer, p is a prime, a is not divisible by p.

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

    Can you explain it thoroughly?

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

      let's say notations p — divisible by p; np — not-divisible by p.

      Now let the polynomials' coefficients look like this:
      a: p p p np p np p p p p ....
      b: p p p p p np p p p p ....

      Now you can see if you take the first occurrence of np in 'a' and first occurrence of np in 'b', in our case it is 3 and 5 respectively (0- indexing) .
      The term formed will be x^(3+5) = x^8.
      And the coefficient of this term in the resultant polynomial will be of the form: k*p + a
      which is never divisible by p.
      Where, k is some integer, p is a prime, a is not divisible by p.

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

        Here's an example where this doesn't seem to work. What am I missing?

        Given:

        f(x): 5x^4 + 5x^3 + [2x^2] + [3x] + 10
        g(x): 5x^4 + 5x^3 + [2x^2] + [2x] + 15
        p: 5
        

        The expressions in [brackets] are not divisible by p. Specifically [2x] and [3x] are the first occurrences that are not divisible by 5.

        h(x) = f(x) * g(x), which will end up having (2x^2 * 2x) + (2x^2 * 3x) = 10x^3, which is divisible by p

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

          let h(x)=summation_from_0_to_n+m-2(cr*x^r) \n
          calculate c2. \n
          c2=15*2*x^2 + 10*2*x^2 + 3*x*2*x. \n
          c2=56*x^2; \n
          hence the ans is 2:^)) \n
          if you didn't understand try calculating every term of h(x).

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

            Thanks. So it seems that the key here is to take the first powers of x that are not divisible by p for both. Every other equivalent power of x is already a multiple of p, and hence won't impact.

            Any later coefficients that are not divisible by p are irrelevant, as their multiplication results in a higher power of x, which does not impact our answer.

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

              i think first power which is not divisible by p is important. \n
              if we take any index from first poly which is not divisive by p and any index from second poly which is not divisible by p, \n
              and calculate its corresponding coefficient, it may give WA, because they may be add up to a factor of p. \n

              so if we take first power, it will not gonna impact out and, \n
              :^)

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

Do we need FFT for polynomial multiplication in C?

I was thinking of solving C but didn't know FFT implementation.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится -13 Проголосовать: не нравится

Why do you take theoroms and make questions out of them . Stupid C really. https://imgur.com/a/NXx553s

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

Am I the only one who left A and B first and solved C then moved to A and don't even saw B.

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

How to solve problem B?

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

Not only annoying B but annoying C this time :(

A understandable solution for problem B is to calculate all the possible strings for every k and sort them.
But the complexity seems a bit dangerous...

NO FST PLZ XD

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

How to solve Problem B?

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

Is it intended to counter Treap's stuff in F? It is even harder than offline solution :)

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

    I think they raised the limit to allow it, there are treap solutions with 3.5s execution time. The problem is that if you have anything that makes the constant slightly bigger it's a ton of time: I used the problem to test splay tree and got 4.9s by inserting in the first way I thought of, then I optimized the insert after the contest to use one splay operation and it's 4s.

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

    No, we did not intend to fail the treap solution. We had the offline segment tree solution that passes in 1.4 s. We raised the limit to allow certain other slow solutions but with same complexity . As tfg rightly mentioned, it's true if you have any part that's unoptimised it really takes a lot of time to pass.

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

task C is great enough to look for some stable and fast fft model xD

btw, really enjoy these tasks! thanks for that

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

I don't get the comments above criticising problem C. It was a brilliant observation/ad-hoc problem.

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

I think problem C is a good ad-hoc problem. Beside, it actually asked us to prove Gauss's lemma.

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

My randomized C solution will fail on this case:

n 2 2
1 1 1 1 1 ... 1
1 1

Thanks I saved my ratings

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

System testing even took more time than the total duration of contest :)

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

How to solve B in O(n^2)?

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

I wonder what should be constraint so FFT solution passes on C...

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

when the scoring will be announced??

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

Yay! I solved three problems in Div2 for the first time!!! :D

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

https://mirror.codeforces.com/contest/1316/submission/72467933 Why I am getting wrong answer in C testcase 7? Ignore the leftrotate and rightrotate, those were for last question xD

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

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

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

When the editorials will be available?

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

https://mirror.codeforces.com/contest/1316/submission/72475791

I am getting wrong answer on testcase 157 by submitting the code mentioned in the link. Can anyone please tell me why is it so?

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

    It's because you intend to find the first coefficient that is not divisible by p , but you put r as 0 initially , so whenever there's a case when the first coefficient you are looking for is at power 0, you skip that one and pick up the next coefficient that's not divisible by p , as your r is still 0.

    Changing initial r as -1 and putting in the check , if r is -1 , only then assign r = i, the code should work .

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

In question C, why is the sum of other numbers not an integral multiple of P?

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

    The solution is you find the first i in first polynomial ( i can be from 0 to n-1 ) such that it's coefficient is not divisible by p. Since all other ak's from k = 0 to i — 1 are divisible by p , the entire thing that you put in initial paranthesis is divisible by p.

    Now we want a find a j in 2nd polynomial, similar to how we found i in first polynomial. Since now all other bk's from k = 0 to j — 1 are divisible by p , the entire thing that you put in second paranthesis is divisible by p .

    Now since ai is not divisible by p and bj is not divisible by p, ai*bj cannot be divisible by p since p is a prime. Hence the entire expression is not divisible by p because ai*bj is not divisible by p and all other terms are.

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

Can anyone please explain problem "B"???I couldn't even understand the tutorial.

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

    Consider any string str for modification for a chosen k and let us write str = AB , where A is the prefix of length k-1 and B is the suffix of length n-k+1.

    Now applying the modification, the modified string is either of form BA or BA' ( where A' is the reverse of the string A) based on the parity difference between k and n, i.e., (n-k)%2 .

    Consider str = "malice" . n = length of string = 6.

    • Now using k = 3, A = "ma" & B = "lice", the modified string is BA , i.e., "licema" . Parity difference is 1 here.
    • Now using k = 4, A = "mal" & B = "ice", the modified string is BA' , i.e., "icelam" . Parity difference is 0 here.

    I hope I haven't made any mistake in the example. I suggest taking a string and trying it out for yourself to note the observation. Understanding the way resultant string is obtained after modification in the 2 cases, we can actually obtain the modified string in O(n) for each k rather than O(n*n). Hence we can check for each k and find the lexicographically smallest string .

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

Why does simply doing FFT give me a wrong answer on test 7 of C? Anyone else submitted using FFT?