AlexSkidanov's blog

By AlexSkidanov, history, 6 years ago, In English

UPD note that the score distribution has changed

UPD2: LHiC found a bug in the author solution of div1-F. We are working on the situation.

UPD3: we found a correct solution for div1-F and both submissions made during the contest pass all the tests against the correct solution. The round remains rated.

Hi, everybody,

Codeforces round 488 for both divisions will take place on Jun/16/2018 19:35 (Moscow time). The round will be 2.5 hours long (which is 30 minutes longer than usual).

The contest is created by NEAR and its friends. NEAR is working on teaching machines to compete in programming competitions. Read our blog post to learn more about the state of the art in the program synthesis today, our vision, and how you can help us bring this vision to reality.

The contest will feature 6 problems for each division, with 4 problems shared across them.

The problems for the contest are from the test rounds hosted on a system JavaBlitz last year. If you participated in any of the JavaBlitz rounds, you shall not participate in this round.

The score distribution in the first division is 500-1000-1000-1500-2250-3000

In the second -- 500-1000-1500-2000-2000-2500

The round is rated for both divisions.

All problems are initially created by myself, Alexander "AlexSkidanov" Skidanov, and by Nikita "FalseMirror" Bosov. David "pieguy" Stolp, Alexander "AlexFetisov" Fetisko, Marcelo "mnaeraxr" Fornet, Nikolay "KAN" Kalinin and Mikhail "cerealguy" Kever helped tremendously ensuring the high quality of the problems.

As a closing note, we are constantly looking for people to help us label competitive programming data for research. Read more here.

Congratulations to winners!

Div. 1:

  1. Um_nik
  2. Errichto
  3. scott_wu
  4. Reyna
  5. matthew99

Div. 2:

  1. conqueror_of_conqueror
  2. Shayan.P
  3. gauss148
  4. kessido
  5. codejudge

The editorial is published here. Thanks for your participation!

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

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

Where is this:"Thanks to MikeMirzayanov for the platform"? :)

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

Which one is true ??!!

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

Wtf,Who the hell is this Near??He oesn't have even a cf handle??

UPD:ITsNear :P

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

So fast problem distribution :)

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

Round in feast

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

The round coincides with Peru-denmark match

Although it's not a very important match but please set the upcoming contests time in such a way that it doesn't coincide with other games

sorry for poor English:)

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

    Nobody cares about Peru-Denmark match ;)

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

      Really true

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

      Come on, man. I may be the only active coder on Codeforces rocking the Danish flag but did you know it is the oldest flag in the world? Give the country some credit!

      (I am not mad about the contest time fyi, I got work taking up my schedule anyway)

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

    Wanna watch this match ? Stop coding and start watching :) no one's gonna disturb you I think :)

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

Hope you spot the references :)

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

NEAR is the name of an anime.

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

Does nobody have a problem with the fact that apparently problems are recycled from JavaBlitz? For me I guess I can't compete in this round as I believe I did JavaBlitz practice rounds (although they were 1 year ago and at this point I don't have idea). But what about people who looked at problems a year ago but didn't compete, and don't quite remember what JavaBlitz even was. Seems like bad habit to me to post contests to Codeforces with problems, that are visible to anybody, and then reuse problems for contest a year later.

But maybe I misunderstand situation and it is not a issue for some reason.

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

    It is a reasonable concern. However the problems were not visible to anybody, we actually tracked all the problem views on JavaBlitz (only logged in users could see the problems), and the total number of people who saw at least one problem across the two rounds is 19

    We sent all of them to Mike, I assume they just won't have an option to register.

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

      So the problems are no longer visible on the Internet? What about the people who know them from word of mouth from th 19 who for sure saw them? Particularly those who will ask those directly to tell them what the problems were.

      Anyway, practice and fun should be the main reasons so I suppose the issue is kind of mute, but I just couldn't help notice than in CF rounds with "known" problems, there are a lot more accepted submissions, which of course disadvantages those who like me, didn't know the problems in advance.

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

It's Near for soo long

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

Flood of contests Thanks MikeMirzayanov for contests.

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

What is the score distribution? and how does it relate to rating?

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

    Those are the maximum scores you can get for each problem (if you solve each in 0:00 time). The score gets decreased as the time goes on, and the final score you get is the sum of the scores of problems you solved (and hacks). It's not directly relevant to your rating, as the rating is affected by your rank in the contest, not the absolute score you got.

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

Coderforces round > Peru vs Denmark

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

Wish you all a happy Eid Mubarak from Bangladesh

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

    This contest is nothing but Eid bonus from codeforces for us. :)

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

Chinese contestants will have to stay up until 3am :(

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

Brazilians contestants are going to miss half of Brazil vs Switzerland match :(

edit: Actually the Brazil match will be on Sunday. The conflict is in the Peru match

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

    ohh .. no .

    i will die

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

      If you had solved one question per comment you post, you would have been LGM by now.

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

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

No its far.

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

EID MUBARAK. Happy Coding.

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

6 problems total, 4 shared. So Div 2 C is Div 1 A.

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

    div.1a will be easier than usual i think.

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

The timing is shifted by 2 hours.

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

hopefully have a world cup theme :)

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

Div.2 D and Div.2 E has the same score. weird

Same thing with Div.1 B and Div.1 C

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

    It's same for Div.2 D and Div.2 E, which is Div.1 B and Div.1 C

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

AlexSkidanov to the contest start!

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

Eid Mubarak to all contestants...

Good luck.

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

CF is working very slow. I'm getting 502 gateway error.

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

Contest on Eid-Day ^_^

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

Oh yeah

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

wtf says in the statement of D, it is impossible to understand

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

    then you should try E, its statement is most ambiguous

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

    I still dont get how D works. Worked a solution based on the explanations. (Though got WA because of weak pretests even though there was 20, but after getting wa, found my mistake)

    Anyway still dont know why i did what i did.

    Maybe it said, there are random pair of points. Find the common number in the pairs that was given to both of them. If there are more than one common points but those 2 persons can still differentiate those then ans is 0 else -1.

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

IMHO, this problems is not about hard interesting ideas, math, algorithms, data structures. It's about clear coding, being very careful, being able to find all cases and being able to test your programm well. It's not bad problems, I just really think it's not codeforces or competitive programming style problems, it should be educational problems for software developers or something.

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

    There was a post a while back about what the best CP sites are, and for me this is why CodeForces is not top. I think this is regularly a problem with CF rounds, just more accentuated in this particular round (at least for Div 2).

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

Is rate of fall of points for a question reduces? As some contestants got odd number of points which I haven't seen before!

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

Well, the most boring contest I have ever seen. Left after reading E. Standard ABCE (just coding problems), couldn't understand what D says.

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

Tfw educational round is more creative than this.

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

How to solve E ? I think about 2 hours for E :|

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

    Calculate Ci = how many numbers less than x from 1 to i. Now you have to calculate number of l, r such that Cr - Cl = k for each k. Do it with FFT.

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

How to solve Div2-D? I didn't even understand it.

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

Most boring 2.5 hours ever :v

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

Contest of short consntrains!

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

How to solve div2 -c ?

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

    Just IF ELSE will DO

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

    First I checked every vertex and the center point of the oblique square, if it is contained in the other square then the answer is YES.

    Then I rotated the coordinates axes of 45 degrees ( https://en.wikipedia.org/wiki/Rotation_of_axes ) and did the opposite.

    It probably isn't the best way

    EDIT: Fuck yes it got accepted

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

      No need to rotate though! Just use a different equation for the rotated square: |x — cx| + |y — cy| <= d/2 where (cx, cy) is the center of the square, and d is the diagonal length.

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

        Yes I know, I couldn't figure the equation. Where did you get it? Because I would have used something with Pythagoras. I don't understand why it works in your way.

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

          Well, just high school math I guess.

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

    Iterate through all integer point in the parallel square, and check if it is in the rotated square (can be done by calculating mahhattan distance to the center of the rotated square).

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

    I tried this and got WA on pretest 10:

    Let the square be ABCD, and we iterate over the points P in the other square. Calculate AB × BP, BC × CP, CD × DP and DA × AP; P is inside ABCD iff all of these complex cross products have the same sign, at which point print yes and exit.

    Swap the squares and do that again. This was all inspired by 29.2 in the PDF in this blog post.

    EDIT: Does not work because doesn't account for the case where the squares intersection region does not include any vertices of the squares. Same is true for my other post below :(

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

    Also, calculating the areas of the four triangle formed by a point P and the sides of ABCD and comparing this with the area of ABCD should work.

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

    Checking if a point is inside a rectangle/square is a standard problem ( check this https://www.geeksforgeeks.org/check-whether-given-point-lies-inside-rectangle-not/ ). Now for all x,y co-ordinates possible from -100 to 100, check if a point lies inside both the squares. If yes, they intersect.

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

    My solution:

    1) Mark all integer points on the edges of a second square.

    2) Iterate through all points inside the first square, check if point is marked.

    3) Mark points in the first square and check second square.

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

      step 3 is not required.

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

        Step 3 is the case when the first square is inside the second one. If you omit it, you will get WA 5.

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

          You marked all the points inside second square, so while you iterate through all points inside first square, you'll find points already marked, since first square completely lies inside second square.

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

            Oh sorry, you are right. I marked points on the edges of a square.

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

    In Div-2C You can also use point in polygon algorithm to check whether any point from any square is inside or on the other square.

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

    for all (x, y) iterate from -100 to 100 and see if any point is found in both square.

    Complexity O( 200 * 200)

    or u can find minX, maxX, minY, maxY and some if else's.

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

share a hack data for problem C 1 1 1 1 just for the people who are too rigorous

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

It is obvious that we should use FFT to solve div1.E, right? I am so regretful that I don't have FFT code...

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

    Maybe karatsuba works too..?

    (Although I failed to code it)

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

How to solve Div2-D? Thank you.

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

    For each pair of each person, we will find out the list of pairs belonging to the other person, that two pairs only have one common number.

    The answer will be:

    • A digit from 1-9: only when all possible sets of 2 pairs have similar common number.

    • "0": Both players can determine the number (since they know their own given pairs, while you lack such informations), but there are different digits that could be the answer (which you cannot decipher, since you lack the aforementioned info).

    • "1": Other cases. Technically, at least one player cannot determine the common number.

    The determination can be done by brute force. From a player's pair, iterate through all pairs of the other player. That pair won't cause ambiguity when either no pairs from the other player have exactly one common number with it, or every pair that does returns the same number.

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

in problem B ,, who else missed that the answer was the maximum number of coins ?

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

    Me. I was using cumulative sum after sorting. Thankfully pretests were good.

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

was this a rated contest??

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

Today my solution for Div1C was hacked. Then I wanted to know if it was hacked because of what type of error (like wrong answer or TLE). To know this I had to make a dummy wrong submission. Doesnt it make sense to also add what type of mistake the hack exploited(Like WA or TLE or maybe RE). Or is there anyway to know it without a dummy submission??

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

    You can see it in "hacks" page.

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

    It can't be TLE because you must have checked the constraints before submitting.

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

      You could have a bug that causes TLE, and sometimes it's hard to accurately analyze how much time a code takes

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

      and can't be WA because you must have implemented your solution before submitting

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

damn. For problem D, I thought the first condition was "if you can determine that number, print 1" for some reason. rip. How did I get 10 pretest cases?

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

    I had to read the statement 10 times to understand it. For me it was very confusing.

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

    Omg, same as me.. I kept thinking for 40 minutes until I saw it.

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

    Yeah, same. As always, reading turns out to be the hardest part of problem solving... .-.

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

What's pretest 8 of D?

I tried to solve D by sorting by descending power-requirement, then doing dp, storing amount of computers with exactly one task currently assigned, and total amount of processors in use. If multiple have the same power-requirement, handle them at once. This has time complexity O(N * N * B), where B is maximum amount of processors a task uses. However, this fails to pretest 8.

Edit:

Participant's output

1289043069

Jury's answer

1289043070

Nice, I somehow managed to misunderstand what it means to round up, I rounded (for example) 0.3 to 0 instead of 1. Quick fix and AC :P

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

I've got WA on Pretest 7 in Problem D. Does anyone know the test?

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

Why the hell there's All pi's are distinct condition in Problem B? I lost time implementing without that condition.

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

    To make coding easier?

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

    stl map

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

    I also didn't read that line and skipped it because C looked more promising. :(

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

    Same here @asgar, didn't even know all pi's were different until i read your statement. Lost 10+ minutes there, plus the drain on every other question after that :'(

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

    Yeah, coding is easier; sort from small to large powers, then iterate over the knights, each time tossing the previous knights' coins into a priority queue.

    Without that condition it's much less clean to add things to the priority queue.

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

When you read Div2B and all the contest you think you need to choose a subset of k killable elements to maximize the sum less than P[i]... and it turns out you ONLY need to choose the k maximum elements under P[i] :( ... What the hell happened to my brain ?! :'(

Solved Div2C and didn't solve the easy peasy Div2B ...

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

The contest of invisible corner cases. Bye-bye rating, hello attention.

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

    You know, I made a lot of incorrect submissions (five, to be precise), and still got my rating increasing from ~1700 to ~1800. A particularly nice thing about CF is that it values correct submissions a lot, even if they are made after many wrong submissions.

    My point is that you should try hard to solve as many problems as possible, even if you have already made some wrong submissions, and never ever give up!

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

Silly solution of div2A. 39292471

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

    It's okay. Given that it's "long time no see"

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

That moment when you realize in problem D you should print the correct number instead of 1......

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

    WTF!!!! I didn't realize that until I read this. FML...

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

      This. In addition to realizing 10 minutes before the contest ends that only the shared number had to be uniquely determined, not necessarily the two pairs. T_T

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

    Got 2 WAs because of this xD

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

    I made 2 wrong submissions due to that :(

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

How to solve div2-E?

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

    To make an enemy spaceship destroyed, one of our ships must stand at the middle point between them.

    Technically, there are 40000 possible positions. But we're not iterating through all of them (It will guarantee a TLE verdict at large tests).

    Let's iterate every ship from the left side, then with each ship iterate every ship from the right side (or you can choose the vice-versa order, doesn't matter).

    Denote the left ship's y-coordinate as y1i, the right ship's y-coordinate as y2j, to destroy both of them one friendly ship must stand at the y-coordinate of (y1i + y2j) / 2 (for simplicity, you might consider only caring about the value (y1i + y2j)). Add this pair of enemy ships to the list of possible takedown pair if standing at the aforementioned y-coordinate.

    Keep only the y-coordinates that if standing there, at least one pair of enemy ships will be destroyed. From this point, you can simply do a quadratic-time-complexity iteration to find out the answer (since the maximum number of valid coordinates cannot exceeds nm).

    Total time complexity: O((nm)2).

    Update: There are times when there exists exactly one y-coordinate that if standing there, a positive number of enemy ships will be destroyed (technically, every enemy ship from both sides would be destroyed). You can handle this case exclusively — the answer will always be n + m. Thanks Aeon for pointing that out (in his reply below). ;)

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

      Actually your solution works at least O(n2 * m2), because you iterate 2 times over all pairs of intersections. And moreover, it will fail on test 1 1 1 1

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

Hey,can a knight in problem B kill a knight with the same power? 3 2 1 2 2 2 2 2 This test i test on my friend and he got ac while i got wa,wtf?

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

Problem B clearly says "Determine if you can with certainty deduce the common number, or if you can determine with certainty that both participants know the number but you do not", although you actually have to determine that number if you can, not just determine if you can do this.

Coordinators and authors, please, I think it's very important to formulate question correctly, what the hell. Never saw this on CF before.

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

    That's one small thing that I think really made me believe I was supposed to print either -1, 0, or 1. Although I can't complain for not carefully reading the output section, the statement definitely could have been clearer.

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

      I actually never read the output section carefully — I have samples for that. That never failed me before.

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

        Yep, I inferred everything from the samples too. They really covered all three possible scenarios (well, according to the misleading problem statement).

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

    This is maybe the hardest thing to do for an author. I know myself how hard it is to avoid words like that. That being said, of course they should try to watch out for that and it is a bad thing.

    My advice is to read the output section anyway and not care much about wording like "you want to find this" in the middle of the statement. Authors often describe the story and only at the end they say what they really want.

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

      I understand that it's hard for the author, I know this myself too and I don't have much complains to him. But there is more than one persons who prepare the contest, they should check things like that. And, yeah, for me it's lessons learned.

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

        It's easy to check if there is a max test for example, or to remember to stress test the intended solution with slower ones. It's harder to watch out for things like this in the statement because it's vague.

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

          Don't agree. They have testers and people who just read their problems and check tests\solution stuff. I'm sure some of them misunderstood statement after reading it, some maybe understood it after a while by themselves, some maybe experienced WA trying to solve it, some maybe understood it after reading authors tests. It's just important to not ignore this, but to tell author: "Your statement is unclear fsr". Maybe I'm wrong because I never prepared CF round by myself, but that's how I see it.

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

            Why are you sure about this? There is some small chance to understand the statement in a wrong way and it's perfectly possible (maybe even likely) that ~5 people that test it understood it correctly.

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

IMHO Div1E is more about having prewritten FFT code rather than good idea

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

how to solve div2B?

UPD: Got mistake, used set instead of multiset.

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

My head started to spin after reading Div2D. What was that! :O

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

I don't like this round.

E is obviously FFT. B + C = 2000 score, E = 2250. If I have templates, I can solve easy ABC, and E, and get good rank. Unfortunately I don't have it so I wasted a lot of time to write by myself.

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

    I don't like,too. I use int to print ans (void write(int x)),so it failed system test 43. It make me have low rating.I think it's unfair.

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

    Why there aren't large ans in pretests?

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

    I do not agree that having templates make problems B and C easy

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

      I wasted time to solve E. It's quite easy to know get an AC with a FFT templates. I want get the AC. Unfortunately I didn't. I should spend my whole time on ABCD, not only on fft.

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

Div2B is so difficult for Div2B =(

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

    Swapping div2B and div2C might have been better. div2 C was pretty straightforward given that you know basics of axis rotation. Moreover, B was a bit more Data structure or rather STL intensive.

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

Who else got WA for DIV2 B on testcase 54?

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

    Instead of set I resubmitted using multiset and it got accepted :'( Just difference of "multi" lead to WA.

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

When you forget to remove % mod from your FFT implementation :/

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

80% of the submission of div2 C are Wrong answers !?

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

When you get AC in E with runtime of 1996ms

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

One hell of system testing, Seeing such dynamics in system testing after a long time.

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

So many Div2 guys with only 2 problems accepted out of 5 with pretests passed. Pretests sucked this round :(.

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

The weakest pertests ever...

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

Systests failed for Div2B because I forgot to add the case for k=0. Could have turned Expert today. Life is not going good.

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

What is so magical about test 78 in Div2-E?

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

Editorial link redirects to this blog itself, please update it AlexSkidanov

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

The link for the editorial is not working.

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

How can this solution pass for div2b as I am iterating over all the powers greater than current power, so looks like N^2 to me.

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

    You break the loop if cnt[it->ss] < k and you increment cnt[it->ss] in each iteration, so you make at most k iterations for each knight. The complexity is O(n*k), but remember that k <= 10. That's why you got AC :)

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

My solution for Div.1D failed on test #11 because the answer is not rounded up. I don't see the point of not including such a test in the pretests or even in the samples, it's just about the format!

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

    I felt the aim of it was to solve the problem using longs instead of doubles.Anyways it was also unclear to me, I had to ask a clarification.

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

Could anyone explain more about the solution of Div2B? (I read the editorial, but still can't grasp the underlying algorithm.) My solution gets TLE for test #52.

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

    Maybe the problem is that you sorting the knights on the number of coins. The test 52 can be specific for your algorithm, like this:

    9 1
    1 2 3 4 5 6 7 8 9
    1 2 3 4 5 6 7 8 9
    
    The same:
    9 1
    9 8 7 6 5 4 3 2 1
    9 8 7 6 5 4 3 2 1
    

    k = 1, for each of 100000 knights you are looking to the first knight with less power. And you are going from the very beginning. So it's too long.(near 10^10 / 2).

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

Div. 2 B has all pretests have the knights' power sorted except test 1.

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

What was the point and use of this line in D div2?
if there is a pair (1,2), there will be no pair (2,1) within the same set

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

Tasks like div1B are definitely not my thing, but at least I'm happy that there was no stuff like "Print -2 if you don't know the number and participants don't know the number, but participants will know the number once you tell them that you don't know the number".

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

    Hold your horses. This is an actual problem statement:

    • Two players are given numbers in the form a - 3 - b - 3 - (b + c + 1) by a GM. Each player only knows his own a, b, c and that their numbers aren't equal.
    • Player 1 says: "Cool. But I don't know if my number is larger than yours."
    • Player 2 says: "Neither do I."
    • Player 1 says: "Neither do I."
    • Player 2 says: "Neither do I."
    • The GM says: "You can keep saying that forever, neither of you can find out which number is larger."
    • Player 1 says: "That's an interesting piece of information, but I still don't know which number is larger."
    • Player 2 says: "Neither do I."
    • Player 1 says: "Neither do I."
    • The GM says: "Again, you can keep saying that forever and neither of you can find out which number is larger."
    • Player 1 says: "Well, I still don't know."
    • Player 2 says: "Neither do I."
    • Player 1 says: "Neither do I."
    • Player 2 says: "Neither do I."
    • The GM says: "We can even keep having the conversation we've just had forever, with me telling you that you can't determine which number is larger from time to time, and you still won't find that out. Actually, I could repeat saying this sentence I just said even a thousand times (at appropriate times) and it would still be true."
    • Player 1 says: "That's really awesome. I still don't know."
    • Player 2 says: "Neither do I."
    • The GM says: "And it still doesn't matter how many times you tell this to each other, you still won't know which number is larger. Not even if I told you this sentence I just said 2017 times, you still wouldn't know."
    • Player 1 says: "Interesting. But I still don't know which number is larger."
    • Player 2 says: "Neither do I."
    • Player 1 says: "Neither do I."
    • Player 2 says: "Neither do I."
    • Player 1 says: "Ha! Now I know which number is larger!"

    (The task is to determine all possible values of player 1's number.)

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

      This is hilarious, who made this problem XD

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

      Is this an actual solvable problem or something you made up specifically for this post? If first option then what are precise conditions on a,b,c?

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

        Actually used in a competition, then in another competition. And it's solvable.

        It's not even that hard, the worst part is comprehending what's going on in the problem statement. a, b, c are positive integers.

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

I declared two arrays like this in the WA code : int a[n], b[n];//n was taken as input before

And changing it to this I got AC : int a[n], b[k];

I got AC here : 39321053 but WA here(on system test) : 39293460

Can anyone please tell me the reason behind this error...? thanks!

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

    Because you put k = 7 elements in the array b allocated for n = 3 elements.

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

    ( 1 ≤ n , m ≤ 10 ) != ( 1 ≤ n ≤ m ≤ 10)

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

I got WA on test 37 for Div 1 B and its test data looks like this: Input: 4 7 9 2 4 1 2 3 2 7 6 1 5 4 7 5 6 3 1 5 8 1 1 4 Output: -1 but if the first player get (2,3) and the second player (3,6) then they should know the answer while we don't know the answer, so we should output 0?

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

    you must print -1 if, for any of the first participant pairs, there are two o more distinct pairs of the other guy that share the same repeated element, because the first participant would not know which one is the other guy's pair (remember you should check the same condition for the second participant pairs).

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

Since there were some people with TLE at E, I decided to share with you a method of writing a good FFT (works even for people who don't even know what FFT is):

  1. Open Codeforces

  2. Find a recent contest in which tourist has participated, 485 (Avito for NTT) fits this criterium.

  3. Copy his namespace

  4. Be happy

Let's practice this method from on so that the problems won't get super-ultra-mega (div 1 E!!!!) complicated because they use FFT.

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

    Nice method, but you shouldn't use foreigh code without author's permission. :)

    But, of course, it's some FFT realizations under public domain anyway.

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

Your text to link here... above is my code for question- Your text to link here...

can someone say what is wrong in it, i was unable to get it?

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

    You have ignored the fact the coins array can have multiple instances of the same element. To be specific,

    if(s.size()>k){
    sum-=(*top);
    s.erase(top);
    }
    

    Lets take the coins array in the test case 10 8 4 8 4 5 9. It goes fine till 10 8 4. When the second 8 is inserted, set.size() does not increase greater than k=2, but this 8 is added to sum.

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

Final contenders for major upsets in the 21st century:

  1. Donald Trump becomes the 45th president of USA
  2. Test case 54 Div2 B
»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I solved E by using divide and conquer and FFT that is O(nlog^2). FFT solution : http://codeforces.net/contest/993/submission/39324259. And I get TLE by using NTT instead of FFT. NTT solution(TLE) : http://codeforces.net/contest/993/submission/39317762. Can only body explain why there are so much difference between these two solutions?

  • »
    »
    6 years ago, # ^ |
    Rev. 2   Vote: I like it +8 Vote: I do not like it
    ll mul(ll a,ll b)
    {
        return ((a * b &mdash; (ll)((long double)a / MOD * b + 1e-6) * MOD) % MOD + MOD) % MOD;
    }
    

    Your mod is way too big, and obviously you can't do this for time.

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

Someone please explain solution for Div2 C

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

    Read the editorial please

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

    I have a cheater solution for that: because all vertices are integer points, the intersection of our two squares will contain an integer point if it is nonempty. Therefore, we can simply check if any of integer points in (-100,-100)..(100,100) lies inside both squares using areas (P is in ABCD iff S(ABCD) = S(ABP) + S(BCP) + S(CDP) + S(DAP), and an area of triangle can be calculated via Heron's formula).

    Take a look at my code if you want to

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

      Hi, thanks for the approach, After considering that there must be a integral point common to both the squares,I tried for each -100<=i<=100 and -100<=j<=100 and checked whether (i,j) is inside both of them by putting the point in the equation of lines of the sides of square, but I am getting WA on test 42. Can you spot the mistake in this approach of checking the existence of common point?

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

        TMHMR, testcase #42 is a corner case when squares intersect at only one corner point. I think that you check if the integer point is strictly between two sides of each square. You should also consider cases when it lies on one of the sides.

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

      It is enough to check only 5 points from each Square, The 4 corners and the center, this will handle all cases , Thus we can solve it with this algorithm for larger x and y. Here is my code :) http://codeforces.net/contest/994/submission/39318762

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

        ofc we can, but this is a solution from the tutorial. I wanted to share another approach.

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

My submission http://codeforces.net/contest/994/submission/39327746 is wrong on test case #93 on codeforces, but it is correct when I run it on my PC and on ideone. https://ideone.com/ksKfLZ

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

Geometryforces Round #488 (Div. 2)