Superty's blog

By Superty, history, 7 years ago, In English

Hello Codeforces!

I would like to invite you to CodeCraft-18, which will take place on Saturday, 20th January, 9:05 PM IST. This is a combined Div. 1 + Div. 2 round and is rated for participants of both divisions.

CodeCraft-18 is part of Felicity, IIIT Hyderabad's most awaited set of events, Threads. With a plethora of intellectually engaging online contests in various fields of programming, mathematics and general knowledge, Threads is a celebration of the spirit of computing and engineering. Other than CodeCraft, we have the Project Euler-style contest Gordian Knot and a jeopardy-style CTF event called Break In, amongst other events.

I would like to thank the CodeCraft team -- FundamentalEq, RohanRTiwari, additya1998, aman_shahi2, born2rule, codelegend, crvineeth97, deepanshugarg, devanshg27, mprocks, nir123 and virus_1010 -- for their amazing work in problemsetting. I would also like to thank vintage_Vlad_Makeev for helping us prepare the problems, and MikeMirzayanov for the great Codeforces and Polygon platforms.

Prizes

  • Top 20 participants win Codeforces T-shirts
  • Top 5 participants from India win Codeforces T-shirts

You will be given 8 problems and 3 hours to solve them. The scoring distribution will be announced later. Good luck!

Update: Scoring is 500 — 1000 — 1500 — 2000 — 2500 — 3000 — 3500 — 3750

Update 2: We would like to apologize about problem F and G, which turned out to be easier than we expected, and about the mistake in the statement of H.

Congrats to the winners!

Top 20:
1. SkyDec
2. Syloviaely
3. matthew99
4. dotorya
5. FizzyDavid
6. laofudasuanbaofushehui
7. ikatanic
8. jcvb
9. Um_nik
10. molamola.
11. rajat1603
12. geniucos
13. MrDindows
14. Radewoosh
15. pavel.savchenkov
16. shanquan2
17. 613
18. JOHNKRAM
19. mxh1999
20. satyaki3794

Top 5 in India:
1. rajat1603
2. satyaki3794
3. jtnydv25
4. akulsareen
5. akashdeep

The editorial is ready!

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

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

20th is Saturday, typo I believe.

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

    You are right, it has been fixed. Thanks.

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

Only 20 T-Shirts. Please added High School Programmer Quote :'(. For Prizes

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

Please update the duration in contest tab! I am seeing 2 hours there!

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

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

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

Why is it not on the home tab yet?

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

    It will attached to the home page soon after today's contest is over.

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

Hope for even amount of geometry and math problems.

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

r_ _ _ _???

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

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

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

I know it is very hard to prepare a contest and we are so thankful about that, but dear authors please double check your solutions. We all prefer not to have 2 consecutive unrated rounds!

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

Are there any prizes for school students in India

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

Will the Project-Euler style contest be conducted on CodeForces ?

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

Expecting 10,000 registrations.

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

Good luck! Have fun! xD

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

Clashes with COCI

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

Here are some past codecraft contests:

2017: Contest, and Editorial

2016: GYM, and Editorial

2015: Contest: GYM, Replay on codechef and Editorial

2014: Replay on codechef

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

I wonder, is there any reason why you are not giving T-Shirts to random participants like last year's contest?

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

Its time tu up my reting. Good luk to me

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

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

So many indians, its their chance to prove that they can be good problem setters.

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

I hope one day i will get a T-shirt from Codeforces. that will be the best recognition of my hard work.

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

Will the drain be adjusted, please?

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

"The scoring distribution will be announced later" ... ?

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

In Problem B, Is there any problem in range of a[i]? check my submission please.

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

problem A: Sample test 2; How 576 is a perfect square????

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

Can't hack solutions , it keeps on loading

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

what a hard contest!!

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

Getting runtime errors on pretest 1 with no error specified for problem C. Can the admin please help? It runs fine on my machine.

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

    same thing happened to me. you are probably using a different compiler. try using custom invocation option. In my case i was using negative indices

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

May be another unrated contest is running..............................

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

    i think they have to unrated the contest because of problem H :D

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

Even though I performed miserably in this round, I must admit this round was pretty neat as the problems were good. Good job!

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

this round should be unrated because of problem H like yesterday contest

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

    I think that, because almost nobody even attempts H, the round should still be rated.

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

    You are talking about 'H'; not 'A' or 'B'. As if you have stood 2nd because of this mistake.

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

I'm mentioned in problem H!

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

waiting for notification, when they say , round is "UNRATED " :P

C problem,,, looks interesting :P ...

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

Is fast enough for D ?

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

How to solve C and D?

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

    C digit dp.
    D answer is yes if there is <= 1 numbers that isn't divisible by X.

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

      How to find that for D?

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

        Make a segment tree where you keep the gcd in each node. A query will point to multiple nodes and you'll pick the only one not divisible by X(if there are more, there is no solution). This node has either 1 or 2 sons with a value not divisible by X. If both values are not divisible by X you have no solution, otherwise just go to the node that isn't divisible by X.

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

      Can you share your code for D?

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

      Your solution to D did not timeout?

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

    C : once you apply operation to N, it must less than or equal 1000. So you just have to pre-calculate k-value for 1 to 1000

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

    C is a DP. cases k = 0, 1 are easy. k = 2, 3, 4. needs a DP., rest k's are 0.

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

      I think C pretests are weak. it doesn't have any test case with k = 1?

      just now i noticed a problem with my k = 1. I output s.size() instead of s.size() - 1

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

Was a N * log(N) + Q * log(N) * log(N) solution supposed to pass D?

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

    yes

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

    I think so, at least pretests, i was able to pass pretests with this complexity.

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

    No. That is what I originally did. You need .

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

      I passed the pretests with a solution that i think is slower that Q log^2 N. Maybe i overestimated my complexity, or you implemented something slower than that.

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

That moment when you realize your C will fail 4 mins before contest end after locking it.

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

    me too, for k = 1? or something else for you?

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

      k = 1. Used it to get 3 blind successful hacks in the end but still RIP rank.

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

        such a bad way to fail a problem :(

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

        Exactly same thing happened to me. So, in the last 2-3 mins, I just put that hacks in other's code. Didn't read them so got 2 unsuccessful hacks as well with 4 successful ones xD

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

          In my opinion, they should have had k=1 in test case. its not something at the core of this problem. .. but maybe that's my defeated soul consoling me..

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

        Haha, I used K = 1 to hack someone else before I realized my code would fail the case too.

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

Is E divide and conquer? If yes, how to merge the answer of 2 sub-trees efficiently?

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

    Maintaining mask of letters will work I think.

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

      Thank you. Oh! I see, you just iterate through 0^mask, 0b1^mask, 0b10^mask, 0b100^mask... right? Now the complexity is some O(26n). Ahhhh...

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

        Can u explain a bit more?

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

          I haven't solved it yet. Here's how I want to merge sub-trees. So use a 26 bit mask to represent the odd/even of letters on the paths that ends at the current node under analysis u.

          If 2 paths p1, p2 ending at u can be connected and form a palindrome path, p1 - u - p2, then, if you xor the mask of p1 and p2, either the resulting mask has only 1 bit set or all bits are 0.

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

            There's only 20 letters, [a, t]. Very important.

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

            What if there is a path p1 ending at u which has mask something like ....000011 and p2 has mask .....000010 so in that case we won't be counting p1?

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

              Since 000011 ^ 000010 = 000001, there's only 1 bit... So p1-u-p2 should also be counted in this case...

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

                But u r not storing the bits except for 00001,00010,00100,01000,10000 for each node right?

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

                  so...in my opinion, u will store all possible masks. since the number of these masks is at most O(n) (# of paths to u from sub-trees), it is acceptable.

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

            I have a doubt. In a subtree there can be atmost N possible masks and when we are merging we have iterate on them. So, isn't the complexity is O(N^2)?

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

              The solution should be a little bit different from dfs, by exploiting the information about the size of sub-trees (centroid decomposition, you may refer to the editorial).

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

                thanks! i didn't know that it is out.

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

Must D be done faster than Qlog^2 or is my segtree implementation just bad?

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

    I do that O(Q log^2 * gcd) with some optimization, and it runs about 2s. (Hope I can pass the system test)

    However, I think the ideal solution may runs in O(Q log * gcd).

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

    My Qlog^2 solution ran pretests in 1092ms

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

      It's possible to implement query() in O(log n) and update() in O(log n * gcd). I think that's the fastest.

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

      How does that work? I use a segment tree and binary search.

      Also, I use the pragma to optimize my code, but it still runs in 2s.

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

        This is my solution:

        Keep a segment tree of gcd()s.

        The query is basically "Is there more than 1 value in this interval, which isn't divisible by X?". You can check it by finding the leftmost and rightmost "bad" index; if they're the same, then there's only 1 bad value.

        Yeah, you can binary search this, but that's not very fast. The segment tree query will produce O(log n) nodes that cover your query interval. Then, you can iterate over them from the left, and when you find one whose (already calculated) gcd is bad, you can locate the leftmost "bad" index in O(log n), by deciding to either go left or right in each layer of the tree. The same thing can be done from the right to the left side, again performing at most one O(log n) traversal.

        Update: O(log n * gcd) Query: O(log n)

        (During the contest, I was too lazy to code this, so my query was O(log n * gcd))

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

          Simple implementation of an update actually works in O(log n + gcd).

          Idea: After each two steps of the Euclid's algorithm, both numbers will be less than half of the original ones. Therefore, the number of steps is bounded by 2*max{a_i}.

          (This should explain faster than expected running times.)

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

        That's pretty much what I did.

        For the queried range, I divided it into 2 parts and recursively went down the segment tree, until reaching a segment of size 1. If during the search, both parts had a gcd not divisible by the guess, that meant, it's wrong. Otherwise I chose the wrong part (if any) for continuation of the search,

        You can check my submission if you want to see it more clearly.

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

How could you solve C?

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

Hacking says that my version of Flash is too low to run. I am running the Flash that came with the latest version of Chrome.

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

For B : Hack Case is

5 1 1 1 2 2

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

What was the hack Case for A ?

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

by a mistake I resubmitted for problem A near the end of the contest and so I got two hundred instead of 490 which was my initial score is there any way for me to get my initial score?

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

what are the hack cases for C ?

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

    111 1

    If you don't write an if() you'll print 3 instead of 2.

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

      I bruteforced for values less than 1000 Maybe mine fill fail on larger values when k == 1

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

Why the third sample input of H is 36?

I think 1 2 3 and 3 2 1 just have a single way to modify. QwQ

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

    For 1 2 3, you can flip 3 or negate 2 3. For 3 2 1, you can flip 2 1 or negate 1.

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

Problem G submission by rajat1603 LOL

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

How did you guys hack problem C?

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

    k = 1, you're supposed to print len(n) — 1

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

I Hope F is better than

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

    Bitset is better than everything!

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

    I see O(N2) solutions with bit masks at the top.

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

    I think it can be done in O((N + Q) * rootN) by keeping a suffix tree over each block of sqrtN. Not sure though, got confused with the implementation details.

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

    Me : How to solve F?

    Some red guy : Do kmp 7000 times

    Me : That's obvious, but it won't run in time

    Some red guy : Why not, CF is super fast

    Me : (facepalm)

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

I know it is O(n^3) but why does it get wrong answer on C: code

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

I really enjoyed the problemset especially the tricky ones. Thank you guys!

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

2 — 1 in last min!!

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

During contest I tried to hack 2 solutions with the test "1 -64". However they both gave unsuccessful verdict. So I copied their code by hand, put it into codeforces compiler and it gave WA! Images: https://imgur.com/a/NrhKb. However, now I put their original codes and it gives correct answer! Could anyone please tell me the difference between their original code and my copies that could cause this? Code1 Code2

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

    Your manual copies look same to the original codes. So, only difference could be the choice of compiler but then I have no idea how would that produce different results.

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

    Could you please tell ids of hacks?

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

    Seems like it's some kind of undefined behavior.

    Reference

    C++ guarantees only that domain error will occur in case of negative x and nothing about return value.

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

      Damn :( I thought since it's the same compiler, the undefined behavior would be the similar. Anyways, thx for clarifying it to me.

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

        I checked C++14 and 11 gives INT_MIN while c++ 5.6.1 gives -64. (at custom test)

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

"A path in the tree is said to be palindromic if at least one permutation of the labels in the path is a palindrome."

Is there any reason to call the special paths in problem E palindromic when the obvious notion of palindromic path is different ? I only noticed the different definition 30 minutes before the end of the contest...

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

    And it didn't help that the first sample didn't distinguish that. :(

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

Anybody knows pretest 5 in problem C? Maybe k=5?

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

lol

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

For C problem, I have doubt, pls someone help me...

question is saying that ,,

He calls a number special if the minimum number of operations to reduce it to 1 is k. ****

so , for the second test case,,,input is like

111111011

2

when I convert binary to integer,,, value is 507,,,

from 1, 507, there are 498 special numbers according to definition of the 'special number'...

then how come answer is 169 ... ( I know answer is 169 for EXACTLY K steps ) ...

I spent whole lot of time on C ,,, could have done D though :| ...

This is my brute force, code,,,

code is here

( this is the code to generate and check special numbers , it takes string(s) and integer(k) as input, and converts binary string to integer value(n) , and then iterates from 1 to n, and for each i check whether it's special number or not )

this is the list of the special numbers

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

    Yes, the statement did confuse me a lot, but here "exactly" is same as minimum number of operations as he any further operations is a wasteful activity on 1.

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

    The problem statement actually means that the minimum number of operations to reduce it to 1 is "exactly" k. Minimum number was mentioned in the statement with respect to the operations needed. Although this is bad on the part of the statement writer since this creates doubt as mentioned by you because the operations needed for a number are fixed and there is no need to minimise the operations. I was also stuck at this for quite a lot of time during the contest.

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

      Maybe they didn't want to tell us that the number of operations was fixed, on purpose, so that we have to figure it out ourselves.

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

        well, next time just give input and output, and we will figure out everything ourself...

        This is ridiculous, I had finished my C quesiton code in just 30-40 minutes,,, and then I was debugging that code for 1 hour,,, then decided to write bruteforce,,, and finally understood that it's "**exactly K**"

        Moreover, we can't make any assumptions ,,,

        in case you want to see my code for C question(considering minimum k)

        code for minimum k steps

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

      He calls a number special if the minimum number of operations to reduce it to 1 is k.

      The word minimum in the above statement changes entire meaning ...

      Now, don't try to fool yourself, and tell me that,,, I should look at the test case and then understand by myself,,,

      I know life is not fair,,, but I had my faith in codeforces, why you do this :( ???

      (JK)

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

      Acctually the number of operations is not fixed because you can keep aplying the operation to number 1 any number of times. So by saying minimum they mean you cannot do that I believe

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

Another Hacking round. It seems to be a hacking contest, not a programming contest.

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

    Cant be worse than me tbh. Solved B, it got hacked. I was like "Yeah, easy fix. Done. No more bugs now." Re-submitted, got accepted, immediately locked and...hacked again XD.

    Lesson: Dont hurry for few points, take time and think over the problem. In the end, thats true- we get hacked because we did mistakes.

    (Anyway, getting hacked> failing systest so...:p )

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

    Why don't you like hacks? maybe it is just because you can't hack?

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

      I can but I think to solve the problem is the matter.

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

        I thiNk that hacking (finding mistakes) is helpful because you learn how not to make your own mistakes.

        Also I solved 3 problems, but the duration of round is 3 hours, so hacking is a good way to waste your own time.

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

      I can, still my opinion is that making three easily hackable problems is not a fine choice for a combined round.

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

please stop systests at this point! haha joke

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

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

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

    i'm so curious for the hack case do you know it ?

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

      5 0 0 1 1 1

      or

      5 0 0 0 1 1

      might work.

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

      You can check out others' solutions to see where you got wrong. The person who hacked you maybe?

      I think that's better than asking for the specific test case, because your algorithm is likely to be already incorrect anyway :p

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

So much failed system tests on C

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

    pretty bad pretests if you ask me..

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

      Actually, I guess that is intended. It makes contest worse not funner.

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

        Exactly. One can get AC after a few minutes with 1/2 additional penalty. But after system test, BOOM, you dropped down by a huge margin for some silly coding error or corner case misses which could have been easily found.

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

          If pretests will include every case, why have them?

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

A good good good contest :) but too bad for me, solving E and not get acc from it just because of my poor coding skills ... :( feel so upset ...

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

if(k == 1){ res--; } and only becaus of this i lost 850 point :(

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

That moment when you got TLE on test 105 problem C... I should change my profile photo...

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

This k=1 case where most solutions count 1 and still get pretest pass is a full killer. I doubt I will be able to find such a corner case ever in my life by myself.

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

Is there some easy solution for problemE rather than DP on tree with bitmask?

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

    I type code slowly, so there seems not enough time for me. So I wish to know some simple implemented solution, thanks!

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

    If you only consider the Centroid Decomposition solution easier, then yes.

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

How to solve F ?

i see that most of the people who solved it used bitset so is it a known algorithm ?

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

Am i the only one solved E with DSU on tree? I was afraid that my solution is wrong cause it run so f*cking fast.

UPD : I tried to choose a random root. And it's even faster now.

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

    no some others use this approach like me :)

    also Arpa use this too ...

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

      But still, my solution is much faster than Arpa's. I don't even know why.

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

    how did u solve it with Dsu on tree?

    can u explain your approach ? :)

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

      Let's choose 1 as the root of the tree.

      We will use Dsu on tree to get these two things :

      1. calc[u] as the number palindromic paths such that Lowest Common Ancestor of start and end vertices is u.
      2. start[u] as the number palindromic paths start or end at u.

      So now, if we have a palindromic path (x, y), this path will pass through u only if lca(x, y) = u or lca(x, y) is not inside SubTree(u).

      So the number of palindromic paths pass through u is

      sum(SIGMA(start(v : subtree(u))) — 2 * SIGMA(calc(v : subtree(u)) + calc(u).

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

So do i get 2 tshirts?

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

    ideally you should

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

    Yes, I think we will. AFAIK, it has happened before too.

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

    The way organizers had mentioned, you should be getting 2 T-shirts but wouldn't it make more sense to pass on one T-shirt to the next winner either in Top-20 World category or Top-5 Indian category? Anyways what value would the 2nd T-shirt of same contest add for you?
    However, you guys are the winners, so it's up to you. Congrats btw!

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

I submitted my solution to problem C and it results in RE at test 5. I tried running the testcase locally, it outputs correct. I am unable to reproduce the error. Can anyone help?

My submission id: 34391810

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

    Try custom invocation and print some debug variables (maybe you forgot to declare some variable — locally it stars with 0 but on codeforces server it starts with something else)

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

    use diagnostics compiler

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

    Adding cout to begin of choose_again() removes RE. So I thing you've somewhere got UB.

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

    Yeah, you've got UB. if last cycle for i = 1 and j = 2 and number s with one 1-bit you access element at index 1, while size of bits is 1. So you've got there UB.

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

      Yeah, I found that out. Was just waiting for the problem to get unlocked for practice again, just to be sure.

      Thanks, anyway! :-)

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

this guy skipped Candidate Master!!

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

Is anybody check the brute-force solution of H?

For (n,d) = (4,2) and (4,3), my submitted solution and brute-force solution both give 268 and 364 respectively. But test outputs give 168 and 264.

My two solutions agree about some small input, so I couldn't recognize what is wrong. If anybody recognizes something wrong in my solution, please gives help. Thanks.

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

    Both players should play optimally. If for some tree Storm will win then Ember won't choose this tree.

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

      Oh, I misread whole problem statement...

      I need to sleep... Thank you!

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

Why did Um_nik disappeared from the scoreboard? I definitely saw him on the scoreboard..

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

    Admins decided that I was heavily affected by issue with problem H (probably because I was the first one to submit a clar about wrong sample), but I certainly wasn't, so they will restore me.

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

      Oh, I got it. Thank you for your response. It was great that you solved problem H finally!

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

    Probably he spent some time on H and found an error in the statement. Since he spent some time there he probably asked to be out of competition

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

I am not able to figure out wrong logic in my approach for C. I precalculated the number of 1s in binary representation from 1 to 1000. Now I start from 1st digit. If it is 1 I have 2 options. Put 1 and move to the next digit or put 0 and make number of 1s equal to all precalculated values with k-1 1s. If it is 0 I move on to the next digit directly. For example k = 2 then I try to make number of 1s equal to 2, 4, 8, 16, 32... so that in next step I get 1.

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

The last year magic was canceled in the scoreboard

UPD: It's fixed

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

WTF is happening with the rating changes?

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

What happened. The rating just disappeared

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

    I guess history just repeated itself :(

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

    They are updating some scores. Usually it is someone who was detected of cheating that acctually wasnt — so they reinsert him in the scoreboard (which requires everyone's rating to be uptaded).

    So no, it does not mean that the contest is unrated

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

      I hope

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

      I am not sure but I guess they are checking Um_nik's submissions because first the contest was made unrated for him (see his comment above). So they have to change the rankings.

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

        Um_nik obligingly pointed on the issue in the H and spent a lot of time to argue his point of view. I've made him "out of competition", but he asked to return him despite he has negative rating change. He is my hero for today!

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

      It is Um_nik but not for cheating but for not bothering a legendsry grandmaster

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

 What happening

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

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

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

Why there is no changes at the top rated board?

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

MikeMirzayanov Hello Mike! I'd like to ask a question. Is there any way to test someone's code with a large file data or a data generator after a contest is completed? After this contest, I've do some analyses for the problems, and found some coders' solution make me confused after calculated the time complexity myself, so I want to do a test to those solutions. Many thanks!!

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

I got Top 20 this time.How can I receive the T-shirt, thanks. I haven't receive any gifts from Codeforces before so that I do not know what to do. @Superty

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

I have question about ProC(testcase 27):

11111100010011110101100110100010001011100111001011001111101111110111001111011011110101100101001000111001000100000011011110110010001000111101001101001010100011 1

It have 158 bytes and we can set every bits to '1' and they all less than N.So why the correct answer is 157?

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

where is the tutorial ?

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

so sad...

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

Please help me why mycode 34405334 for problem C is getting MLE, my sloution is somewhat similiar to the editorial.

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

    You have initialised an array with size 4*10^8 bytes. C++ has a limit on its array size to around 2*10^7 bytes.

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

      Oh I added 1 0 extra and every time ignored it while debugging. Thanks

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

Can anyone tell me what's going on? Yesterday on system tests I got TL for problem D. But after some hours I send absolutely the same code and got accepted. How does it works?

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

    yeah with 4 ms difference from tl

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

      It isn't important, I'm don't understand how two same solutions can work for different times.

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

        System load is probably the factor :)

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

          I think CF should seriously think about this problem. For example;e someone can got accepted on pretests in round time and after that get TL on the same tests on system testing only because system load...

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

Thanks for very interesting problems

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

Can anyone explain the sample tc #2 for Div. 2 C.

If I'm not wrong, we will take all the numbers with 2 bits set, 4 bits set and 8 bits set.

Because 11000000 -> 010 -> 001

Similarly, 1111000 -> 100 -> 001

And, 11111111 -> 1000 -> 001

But C(n, 2) + C(n, 4) + C(n, 8) exceeds 169.

Please, point out my mistake. Thanks in advance.

Edit : I was computing C(n, 4) wrong. So stupid of me.

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

The contest problems were amazing , I solved only 2 of them , but got some rating + , so I am happy with it :D