By lewin, 2 years ago, In English,

Hello Codeforces!

I invite all of you to participate in a special Codeforces round. It will take place on 29 Jan, 17:05 UTC. It will not be a usual round. Thanks to Wunder Fund, the best participants will win prizes and souvenirs. Here are some words from Wunder Fund:

Our company is situated in the center of Moscow. We are engaged in high-frequency trading — developing high-performance systems and algorithms for automated trading in financial markets. In this area algorithms and data structures (that you love to invent and implement) are vital. Our systems should process transactions in milliseconds! High-frequency trading is a continuous competition of the best programmers and mathematicians around the world. By joining us, you will become a part of this exciting challenge.

We offer interesting and challenging tasks for the development of low latency for enthusiastic researchers and programmers. Flexible and no bureaucracy, decisions are taken quickly and implemented. We are a small team, so you will immediately become a significant part of it. Understand the economics and finance is not required, but the algorithms and data structures is what we need.

Are Russian speaking and ready to live in Moscow? Join us! Visit our website for more information.

We will be happy to give participants prizes and gifts:

  • 1 place — PlayStation 4
  • 2 place — Xbox One
  • 3-5 places — Sega MegaDrive 16bit with games
  • 1-50 places — Wunder Fund T-Shirts!
  • 51-500 places — 50 T-Shirts to random participants!


Interested in the work on Wunder Fund?

I want to thank the following people for helping me with this round:

  • GlebsHP for his help in reviewing problems and assistance in preparation for the round.
  • LiChenKoh, AlexFetisov, and winger for testing problems.
  • Delinur for translations.
  • MikeMirzayanov for Codeforces and Polygon systems.
  • and of course Wunder Fund for sponsoring the round.

I hope to see you all at the round. Good luck and have fun! :)

If you'd like some practice before the round, you can look over some of my past rounds that I've written (links here: A B C). I will try to give you all some more interesting problems to solve.

UPD1: The round will be 2 hours and 7 problems. Unfortunately, there are some time conflicts, so we are unable to extend the duration of the round. The score distribution will be 500-1000-1500-1750-2500-2750-3500. Note that some problems that we thought are harder may actually be easier for you, so I encourage you to read all problems.

UPD2: The editorial is published. Congratulations to the winners

  1. Egor
  2. Petr
  3. Um_nik
  4. RomaWhite
  5. Sampson
 
 
 
 
  • Vote: I like it  
  • +707
  • Vote: I do not like it  

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

Will it be rated round?

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

    Yes, it will be a rated round.

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

      Is it gonna be 5 problems in 2 hours?

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

        This has not been finalized yet. I can say that it will be between 5-7 problems in 2-2.5 hours (and maybe combined div1+div2). However, we have not yet decided, but I will update the post when I find out.

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

          This is neither here nor there, but do you work for / are affiliated with this Wunder Fund, or did you simply write problems for a round sponsored by them?

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

            I am not affiliated with Wunder Fund. Basically, I wrote some problems for a regular Codeforces round, but then Wunder Fund offered to sponsor a round at around the same time. I felt very lucky to have a opportunity to write for a company sponsored round, as there will be prizes and more participants.

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

    I cant understand the downvotes, i had a query and i asked it.

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

      This thing happened to me a few days earlier as well! I don't why this happens.

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

Hope to have Some Short & Easy to Understandable Problem Statement in this Contest . Good Luck to All & Me.

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

Let it be combined DIV 1 and DIV 2. It will be more interesting and challenging for the DIV 2 coders as well.

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

My first reaction was, lewin is the setter, the problems will be awesome :D

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

And there will be a lot div 1 contestant participating in div 2 to get prizes :'(

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

tourist gonna play everyday PS4 :)

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

Prizes and gifts only for Div1?

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

    We are planning to merge divisions, it will be common problemset with 7 problem. Everybody can win prizes!

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

      the contests page say duration is 2 hours, but usually combined rounds are extended by half an hour, so will you keep the duration 2 hours?

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

    Nope. See 51-500 get shirts on random basis. So, try your best, you can be lucky.

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

3-5 places = the best prize

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

I can not wait my school holiday which starts with big CF round, continue with World CodeSprint, Serbian Qualifications Round, Codechef Lunchtime, Codeforces div 2 round and finishing with HourRank. This will be an awesome weekend and my parents will kill me because I am using computer so much :D

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

    Win Playstation 4 so you can use your computer less and make your parents happy :)

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

      It is bigger probability to go to some shop and steal PS4 than win some prize on the official contest :P

      Even I haven't got t-shirts which I won before 8 months :)

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

      Prizes and gifts only for Div1?

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

I hope it's a combined round even though I always fail big time in these for some reason. Let's see how it goes this time :D Hopefully it can be better, especially that Lewin is setting this round. I liked your problems in Round 309.

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

PS4 for the first place, Xbone for the second place. You also think the PS4 is better?
*grabs popcorn waiting for xbox and ps4 fanboys to start console war*

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

I loved your last round specially that problem about combinatorics !!

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

What if tourist preferred Xbox than PS4?

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

    what if he already has both from previous contest wins?

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

    I think there should be an option for every winner to take the prize of a beaten one if they wish.

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

    I guess in this case he can make some incorrect hacks or extra submits.

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

    Is that why tourist didn't participate?

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

memes)

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

can i join if my age is less than 18 (i am in school not university) ?

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

    They will never choose you even if you were 18++.

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

    Why on earth wouldn't you be able to join?

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

      "Note, Wunder Fund is a Russian-speaking company" -- did you noticed that?

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

        Well, technically being an adult and speaking Russian are kind of unrelated skills.

        Also, I took 'join' in his comment to mean the joining the round, not the company.

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

          well, if you didn't mean the company, then you were ambiguously so funny.

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

        Russian can be learned — maybe not in big favour today, but there were times when physists, chessmasters (etc) learned Russian just to be able to read Russian books, so why not? If you set such goal and put yourself in correct environment you can get speaking simple Russian within few months. I bet guys in WunderFund would be enthusiastic to help. But first thing to do is probably to reverse the graph. Mirroring across vertical axis would look much better.

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

    Reason is there ,and here

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

    sure!

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

As div.1 and div.2 combined, I think the contest duration should be increased at least 30 mins to have more time to challenge and solve problems

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

Легкий рейтинг++ для Div. 2)

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

Why not Nintendo!? Though I think it's impossible for me to get one:)

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

В описание приза есть опечатка, там написано "сувениврные футболки Wunder Fund".

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

so there's a high probability that dude at rank #51 won't get a t-shirt....

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

    Higher than for rank #600 so I guess it's still optimal to fight for a good place.

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

What about rooms? Will they also be combined? Please say no!

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

    No. All rooms aren't combined into a huge room :P

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

      I think he meant will div.2 participants can be in same room with div.1 participants.

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

    Please say no!

    Why?

    Hacked is better than failed system tests.

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

      If your solusion doesn't use hashing)

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

      Because there will be more probability of hacking div 2 coder's solution than div 1 coder's solution.

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

I really hope that Pretests would be strong enough, because it sucks when someone spends half the time working on a hard problem and gets the same position of someone who spent all the time refreshing the room page for new people to hack.

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

    IMO, being able to hack a lot of people has his own merits. Debugging is pretty important in software development, especially video games (look: literally any Ubisoft PC Game).

    Hence, I believe that the pretests shouldn't be EXTREMELY weak. Just somewhere between "hacked by a little toddler" and "pretests = systests". Just so that people that are ACTUALLY pretty good at debugging are able to shine, while the regular coders aren't shut down either.

    With the exception of hash coders. I hate you guys with passion, you wonderful, gambling luckers!

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

      My comment is based on my experience from the last round. After I solved three tasks, I found hacks, went to my room and started hacking. There were too many people to hack that I didn't even have time to read the fourth and fifth problems properly, although they weren't hard, but I don't regret it because thanks to hacks in the Standings I was among participants who solved 4 problems. I'm just thinking that it would have been much more fun if I spent time solving the rest of the problems rather than refreshing the room.

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

it will be a rated contest

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

rated contest

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

The contest is prepared by lewin ==> the contest is greatfull :D

Good luck!

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

I believe you guys forgot to send an email announcement.

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

    Nice, I got it right as soon as I posted this comment.

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

it is midnight again where i am when the contest is supposed to hold which means that i may miss again. i wish everyone who will be in the race could get good marks.*^_^*

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

oh lots of contests these days !!

ENJOY !

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

Will the problems be sorted according to difficulty?

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

    It depends on score distribution which will be announced just before contest

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

why is it so late? I thought it is always at 2pm(GMT)

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

so combined round and only 2 hours. pretty interesting.

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

What way you will use to choose random prizes? For example in one of past cf rounds python code posted on the blog and rand seed was id of last submit in contest.

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

Is the number of problems and duration of the contest finalized?

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

When you're trying to win all prizes

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

    iam sure nobody can't win all prizes !!! but trying is good :))

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

    I don't want to win Prizes . I just want to Solve Problems .

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

    Gaming?...Why???

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

Why so much hate for trunghai95? Whatever he comments gets down voted so brutally :p Or, am I gonna get it now? :/

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

will the rating system be changed (because it's div 1+ div2) or will it stay the same???

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

6699 registered! Interesting number (=

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

7 rpoblems and only 2 hours.

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

CF running slow for me. Not a good sign.

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

Why has registration been closed? Please open registration — the competition hasn't even started yet.

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

Its saying i am not allowed to view the contest.

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

Random T-Shirt Winners will be determined using the following code (with the help of testlib). We will run the code with the only command line parameter — the points of participant on the place 500 (or total points in case of tie).

====

Случайные обладатели 50 сувенирных футболок будут определены с помощью следующего кода (использует testlib). Код будет запущен с единственным параметром командной строки — количеством баллов у участника на 500-м месте (или суммой по всем таким участникам, если несколько займут 500-е место).

====

#include "testlib.h"
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char* argv[])
{
    registerGen(argc, argv, 1);
    
    vector<int> places;
    for (int i = 51; i <= 500; i++)
        places.push_back(i);
    shuffle(places.begin(), places.end());

    cout << "T-Shirt Random Winners:";
    for (int i = 0; i < 50; i++)
        cout << " " << places[i];
    cout << endl;
}
»
2 years ago, # |
  Vote: I like it +57 Vote: I do not like it

Today: funny CF handles!

[user:http://codeforces.com/profile/CantGetAnyACWhyAmISoWeak]

Doesn't seem to be true, considering he's somewhere above 60th place now.

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

short and nice questions...enjoyed solving :D

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

At problem D, when X was equal to Y, I printed N * X instead of (N-1) * X. I locked the problem, then I got hacked. Everything else was correct.

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

    if X < Y then answer is X * (vertices in longest path) + Y * (remaining vertices).
    Else answer = Y * (vertices — 1)
    Is this correct ?

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

      Incorrect.
      3 2 1
      1 2
      1 3

      Write answer — 3 (1->2->3)

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

      No, if x < y you can use multiple paths in the tree. Let m be the largest number such that there is a set of m edges which forms a collection of vertex disjoint paths (i.e. no three edges share the same vertex) then the answer is m * x + (n - m - 1) * y.

      Conversely, if y < x then the graph could be a star, in which case you'd have to use an edge with weight x.

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

      It depends what you mean by "vertices in longest path". I'd rather said "max total length of set of paths", because it could consists not connected sub-paths.

      And it surely wrong for X > Y case. It could be "x + y * (n — 2)".

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

      For X<Y, it fails if you have this:

      6 1 2
      1 2
      2 3
      3 5
      4 5
      5 6
      

      You can go 1->2->3, then jump to 4 (by a non-tree edge), then 4->5->6.

      For X > Y, it fails if you have:

      3 2 1
      1 2
      2 3
      

      Here it's impossible not to use an edge from the tree.

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

        I got my mistake, any way thanks

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

    I could not pass the 3rd pretest until the last 3 minutes, and realized that I checked long long everywhere except printf("%d"). Could be a crazy fail too :D

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

      But you've found your mistake, I still can't:D

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

    well next time don't add unneeded ifs:)
    I bet both solution for y > x and y < x would give right answer for x = y automatically

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

Imho, 2 hours is not enough for 7 tasks. Besides that, nice tasks :)

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

    You have passed pretests in only three problems) And no one have solved G. But tasks were beautiful, I agree with you

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

What is the hacking testcase of Problem C ?

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

    For my solution it was: 4 0 0 2 0 1 0 1 2

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

    As I guess, something like this: 4 1 1 2 1 3 1 5 5 But I don't know exactly and I Haven't enough time to hack anyone with this test

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

Great to see eatmore performing again.

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

I want to ask for a bit of feedback on my code.

I coded E, a "standard" segtree (rotation angle + translation vector), except it is TLE-ing pretty badly. Could someone try to figure out why, by reading my code? It should be fairly understandable.

http://codeforces.com/contest/618/submission/15662186

Thanks in advance.

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

    Well I know from practice that sin and cos are waaay too slow. Maybe you should have saved them in arrays sin[360], cos[360]? Try it.

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

      I believe this still gets TLE.

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

        Try getting rid of cout. I do see sync_with_stdio(0), but on my system changing cout with printf optimizes 2s out of 7s (after cosines are already precalculated), even if I move << fixed << setprecision out of the loop.

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

          This is really weird. In custom test, I designed some test cases for n = m = 3e5, and they got TLE. But now it is working pretty fast when I actually submit. This is confusing to me.

          Thanks anyways.

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

            I think it's something about CF running several solutions on the same machine (but different cores). Try asking MikeMirzayanov to investigate if you're absolutely sure that it's CF-related problem.

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

Okay please tell me how to solve D. I understand that if x<y we need to find the diameter of the tree and the answer will be diameter*x+(n-1-diameter)*y. And if x>=y answer will be (n-1)*y or ((n-2)*y+x). Whats wrong in this?

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

    It's not diameter. Here's a tree.

    1 2

    1 3

    1 4

    4 5

    4 6

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

    Not a diameter, you need to split the tree into lines such that the sum of lengthes is maximal.

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

    First of all, watch out for x > y and n = 1 read the problem statement.

    And if x ≤ y, we want to split the tree into as few paths as possible. Tree DP.

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

      n cannot be 1. (2 ≤ n ≤ 200 000, 1 ≤ x, y ≤ 109)

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

      n is at least 2; read problem statement more carefully.

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

      n is >= 2 from problem statement.

      I noticed that in case where x > y one should watch for single vertex with degree n-1, as it forces you to use cost x at least once. Maybe I am wrong.

      On Tree DP — sorry for silly question — is it possible to split tree in less then (number of leaves — 1) paths? Can you give an example or somewhere to look for it.

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

        It depends what do you mean that path is. For example

        6 1 2

        1 2

        2 3

        4 5

        5 6

        2 5

        has 4 leaves, but you can use 4 of its 5 paths (all except 2 5).

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

          Thank you, that was illuminating :) Now I know my mistake.

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

      Got my mistake.

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

    you could add to path not only diameter. Also you could add some more edges from tree.

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

I'm good at geometry:( I think Problem C can be solved by PolarAngleSort,but I failed on test4.

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

    In problem C, I find first three points that made a triangle. Then I iterate over all other point, if a point is inside the current triangle, replace any vertex of the triangle with that point; if a point is on an edge of the current triangle, replace any node of that segment with that point.

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

    No need to do polar angle sort, just sort by X (or Y). First two points will be in the answer. Last point will be the first point not on the same line as first two points.

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

my submission before 5 seconds did not go into submission queue.. T.T

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

    I pressed submit 50 seconds before the end and still failed to submit — looks like it wasn't a good idea. Anyway I don't think my submission was good, so I actually saved 50 points :)

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

      As I understand, you won't be punished for 50 points if it won't pass pretests, only if got AC. Not sure about system testing.

      Anyway, it is a usual thing — last 5 minutes of every contest is very dangerous time to submit anything :)

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

        If you are correct, then this is second place where Codeforces is factually incorrect — admins, please fix it!

        First place is Help tab in top menu — if you press it and scan through the rules you will see that Div.1 still starts from 1,700+. In both Russian and English version. I reported to Mike, but he was probably too busy.

        For submissions penalty — during the contests, this is what text on the right tab says — "you get 50 points penalty for each unsuccessful submission except if it fails on first pretest, etc." — at least in Russian version.

        Admins, please fix!!

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

          I'm not sure how it supposed to be, but just checked some older contests and in fact:

          1) No penalty for wrong submissions if you haven't got AC for this task

          2) No penalty for AC submissions that failed system testing

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

          If it's the penalty of problem AC score and not of total score, it's correct.

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

    I submitted before 10 sec the problem C

    It went in the queue but how frustrated I was when i realized I did not erase a misplaced "return 0 ;" that I used when debugging :(

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

      About same case for my Problem D where I forgot to comment out freopen -_-

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

How to find minimum area triangle in O^2?

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

I know I will sound stupid, but I couldn't solve Problem A... (I didn't even try the other problems) My final submission was: http://codeforces.com/contest/618/submission/15665677 which seems to do something different than what problem A requests. Why??? What did I get wrong?

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

    You could have just simulated the process in O(N) . (Look Here)[http://codeforces.com/contest/618/submission/15651613]

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

one silly mistake and rank moved back a 1000 places >_< .

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

Please don't do this. Either submit a bad solution early, or don't submit a solution at all. That makes us, hack hunters really thirsty...

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

    wow.. it's amazing that the code above could pass pretests

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

Open questions:

1) is N!=NP ?

2) What is the fastest algorithm for multiplication of two n-digit numbers?

3) Can the rotation distance between two binary trees be computed in polynomial time?

4) Will a day come in future that Codeforces server problems be permanently solved?

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

Problem C — Time limit exceeded on test 84... :(

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

I got runtime error in case 87 on problem C, I have absolutely no idea how that could have happened. Here is my submission: 15659929

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

    Seems to me like you sent wrong link.

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

      Oh yeah, my bad. Thanks, I fixed it.

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

        To your quection: in first cycle mejor can be exactly 4 * 10^18. So in this case you will get uninitialized s, and I don't know maximum possible major in second cycle (maybe >= 4 * 10^8 ant in this case you will get unitialized t)

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

    No "return 0;" in main.

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

      Yeah, that is why he he/she passed previous 84 tests:D

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

      It's allowed in C/C++, compiler will treat that as return 0;. But that's behavior specific for the main function only.

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

    It's because of mejor=4e18. 4·1018 is too small "infinity" when looking for the farthest point when are up to 109 by absolute value. So, the s variables is not set after the first loop and behavior afterwards is undefined.

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

A solution to the hard case of D can be found here:

http://www.austms.org.au/Publ/Jamsb/V44P2/pdf/1761.pdf

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

Why didn't you include at least test with n = 2 and x > y in pretests for D? There are still other corner cases for hacking.

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

    I didn't include any cases where the tree is a star and x > y. For n<=3, the only possible tree is a star.

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

All problems are very excellent. Thanks to Wunder Fund Company.:)

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

chill bro, it's A and it's not easy to hack this guy. Why would someone try so hard on A?

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

Wow, so many fails on problem C.

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

RomaWhite, maybe, is the unluckiest human in the whole world now... 1 point form XBox One :(

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

    Testing is not finished yet, so he could finish on worse place.

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

      When It was 97 percent of testing I thought that nothing can be changed at the top of the table. That was my stupidity. Egor have sent solution when it was 1 hour and 59 minutes. Congratulations to him!

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

    on the other hand, Wunder Fund are lucky because that point avoided the headache to them deciding who will win the Xbox

    UPD: now both dropped one place to 3rd and 4th so no one is lucky and no one is unlucky

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

      That was my mistake, I am so sorry for my previous comment. But now Um_nik is in 6 points from XBox One)

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

    And now he won't...(rank 4)

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

Interesting that this solution that doesn't map the indices passes the tests: http://codeforces.com/contest/618/submission/15664708.

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

    I think you're wrong. Solution requires two arrays of points — input array and sorted array. Answer building by sorted array. And indexes of input array are printed.

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

      You are completely right.

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

connor: blue, extremely high. His previous results aren't that great. Seems suspicious.

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

    See this one's contests history: xuanhien070594

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

    Take it easy! Just think like, he is better than you. maybe he doesn't always take the contests seriously like you?

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

      A lot of assumptions for an unrated user!

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

        hi~ Sorry About that. Truth to tell, connor is my small id (alternate id)

        After ACM-ICPC World Final 2015, I stop using kybconnor in TC & CF. I also stop training after that. but I still enjoy participating algorithm contest. So I bring back connor and ronnoc.

        QwQ

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

Can I see my ranking considering only div. 2 participants?

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

Hello guys,can someone please give me any hint on how could i solve problem B? Cheers

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

I didn't participate but I had this probably bad idea for C : take any point, then take its closest neighboor, and finally take the closest point that is not in line with those two points. So far I didn't see where it fails, can anyone show me where it fails? edit : it works

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

    This is correct, since this third point will be on the line that is parallel to the line that connects the first and the second point and is the closest to this line.

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

      Thanks ! It seemed too simple with all those hacks and red coders weren't so fast for such a simple algorithm. Maybe I would have failed anyways because of int overflow in vectorial product (had this idea late).

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

    As solution it seems correct. But it depends how you implement it — bruteforcing will be O(N^2) and it is TLE.

    I solved it a bit differently in O(N):

    1. Find valid triangle: take first two points and iterate for others, first one that is not on the same line = got valid triangle.

    2. Iterate over all other points. Check if point is inside triangle, if so — replace one of old 3 points with new one so we will have valid triangle again.

    UPD: In second step more precise description will be: "Check if point is inside or on the edge of triangle".

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

      This solution is wrong when between first two points exist the thrid one and all three are colinear.

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

        Nope it is not.

        Maybe I wasn't too clear with description, in second step it is more precise to say that "if point is INSIDE OR ON EDGE of triangle".

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

        All N points are never collinear . It's mentioned in the statement .

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

      I thought about O(N log N) : I sort the points by distance from the first point.

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

      I solved it a bit differently from yours in O(N):

      The first point in answer is the first point in input data. Then choose closest point to it from others. Then choose closest point to the segment of to points that we already have. Also, this third point mustn't lie on the line made from two already choosed points. Got AC, but your solution, I think, more easy to prove and understand.

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

    i did the same it was accepted , the approach is correct http://codeforces.com/contest/618/submission/15660749

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

You forget about overflow and you get Wrong answer on test 93 :/

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

round is rated or unrated ????

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

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

    A lot of test cases and big timeouts (2-8 seconds each). E.g. right now some E solution is running on test case #53 and each could be 8 seconds. And it is only one participant.

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

Int fu**ked me on test case "93" problem C

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

    Same here ! Submitted C thrice ( once after getting hacked ). All that for a WA because of overflow :(

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

And congratulations for 51st place to: FatalEagle!

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

    For the past 5 minutes I was watching aropan's submission, hoping that test 67 might be some strong TLE case.

    Nonetheless, congrats to aropan for that incredible luck in server timing :)

    Edit: Reached IGM for the first time, so this contest is still a success for me!

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

      For the past 5 minutes I was watching aropan's submission too.

      Thanks for the congratations.

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

    FatalEagle be like

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

Somehow I thought that in problem D there is no Hamiltonian path avoiding edges of path on 4 vertices. That is the only testcase my solution fails.

This case wasn't in the system test, but sadly one other competitor in our room made the same mistake and I hacked his solution. As you probably know, successful hacking cases are added to system test.

If I didn't hack him, we would probably both passed :-(

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

    lol

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

    I thought that too. In graph 1->2->3->4 there is not Hamiltonian path if you start from vertex #1, But if you start from 2, 2->4->1->3 is possible path.

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

    I think you did the good thing in that situation. Of course in hindsight you shouldn't have hacked, but in contest you couldn't know how common that bug was (so other people would make these hacks) or that there weren't 4 node test cases. If you were at a harder problem, which few people submitted, then that's another story.

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

That's why I like TC SRM the most :( no problem for int or long long .

WA at 93th

AC

whatever my logic was right. I should be happy :)

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

    You probably should add after "I will always use scanf and printf", "I will always use at least int64 type" :)

    Really almost every contest have int32 overflow in some form. And in many tasks it is present to cut some specific fast algorithms, like counting in array where index = value.

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

      True :) Actually Div 1 & Div 2 combine contest never went good for me. Today i was hoping to break this :p Anyway it was a great contest .

      Thank you lewin :)

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

What is wrong in this approach for problem C? First i am finding two leftmost points i.e. points with minimum x co-ordinates. Then i check for all other points such that they donot from a line with these two points and r1 ^ 2 + r2 ^ 2 is minimum where r1 and r2 are distances of the point from first and second point.

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

    E.g. if you have 5 points with the same X value you just pick first two, while other three could be inside them. So they will be inside the triangle that you've found.

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

      But in that case, whichever triangle you form will have zero area. That is not valid.

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

        E.g. you have points:

        0 1
        0 3
        0 2
        1 1
        

        Your algo will pick points 1 2 and 4 as a result. And it is wrong, because point 3 is inside this triangle. Valid answer will be 1 3 4 or 2 3 4.

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

          Thanks for that case. But i am still getting wrong answer. Now i am finding two points with minimum x and if they are equal then i am finding points with minimum y.

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

            I'm not sure, but it is possible there are two triangles (p1 p2 p3) and (p1 p2 p4), where distance from p3 and p4 would be equals and p4 would be inside (p1 p2 p3). But I'm not sure.

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

              Thanks a lot for debugging! :)

              I guess the condition r1 ^ 2 + r2 ^ 2 should be minimum was wrong ( I don't know why ). I just changed it to finding third point with minimum value of x and minimum value of y and it got accepted.

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

            didnt debug your code . Just wanted to suggest that finding 2 points with minimum x coord can be done easily by sorting and picking the first two points . Refer this .

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

Can any body tell me why my approach is wrong for C

sort point by x .

for each 3 consecutive points make sure that their not in the same line ( horizontally or vertically ) if its the case print these 3 points and return .

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

    It was the right idea to solve C . May be Int flow issue was there same as me . btw its not essential that only they will only horizontally or vertically in line . point ( 0 , 0 ) , point( 1 , 1 ) and point( 2 , 2 ) can also form a line .

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

    if you only sort by x , then you could choose 1 point on a vertical line ( P ) and 3 on the next one( P1,P2,P3). In that case, you may choose P , P1 and P3 where P2 is inside of the triangle(on the border). You should sort by y too

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

    It's not enough. For example, points A(0,0), B(1,1) and C(2,2) can't form a triangle, in spite of they don't have the same x or y. You should check that the area of that triangle is 0. If it's not 0, print that 3 points.

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

    The approach is broadly correct. I just implemented it to test: 15667843. However:

    1. it's not enough to sort just by x (or y) coordinate; points that have the same x coordinate should be sorted by y coordinate (x, respectively).

    2. points can be on the same line that is neither horizontal nor vertical; this case should be recognized and skipped.

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

When the T-shirts will be announced?

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

Hello...this is my third contest on codeforces. In my first two contests I only solved one question. Today I solved two but my rating decreased! Can somebody explain this to me ? Is it because that this round is a combined round ?

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

    Rating increases if you solved better (more tasks OR equal, but faster) than the participants with the same level (or greater) as you.

    And it decreases, if you solved lesser or slower.

    So it is not based on the amount of solved tasks itself, but on the comparison on your peers.

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

    The Rating increases does not depend fully on how much problems you have solved in the round. It depends also on the time you have spend solving the problems. Try to solve problems fast.

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

good contest

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

Problems with awesome quality. Nice, lewin. And for me drawings in E were extremely helpful. Thanks for a round.

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

Hello, what can i do to make my code more efficient? thanks. http://codeforces.com/contest/618/submission/15668412 it's O(nlog) 0.5 seg on test 4

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

    Just use scanf instead of cin ,your code is fine .

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

      you are right! In efficiency,is there a lot of difference between cin and scan? how many milisec?

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

        Difference isn't big but you must write ios_base::sync_with_stdio(0) when using iostream (cin, cout).

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

        Your code using scanf take only 93 ms.

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

Finally returned my yellow, thanks for the round! And like it if your first submission for problem D was a diameter too!

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

    First idea was diameter, was about to code it, but then looked at the case with 2 large chains and realized that it's something else.

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

I got Wrong Answer on test 15 in problem C, but when I run it with the same code in my computer, I get a different output. How is it possible?? this is my submission http://codeforces.com/contest/618/submission/15662738

  • »
    »
    2 years ago, # ^ |
      Vote: I like it +3 Vote: I do not like it
    1. Precision
    2. Wrong dmax

    15672460

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

      Thank you, I will be more careful with precision and bounds. By the way, #define double long double ???????? I didn't know that it's possible to do that.

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

        C preprocessor operates with text, nothing more complicated. It doesn't know what the double is so you can replace that way anything you want.

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

In problem C, my submission gives output 1 1 2 in CF . But, in my pc it gives 1 2 3 . Why is this happening ?

http://codeforces.com/contest/618/submission/15671958

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

    Whenever there are large value such as 10 ^ 9 you should use double constant instead of default float constant. Change 1.0 to 1.0L to get accepted.

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

    Short answer: precision. Your solution with long double passed 15672148.

    Long answer: try to avoid floats as much as possible. For example in my solution 15657222 I use fact that you can compare the squares of the distances to determine which is shorter so there is no need to take root. Also I search third point by comparing areas of triangles and they are always N/2, where N is some non-negative integer, so I simply doubled them. Owing to those facts I have only integer operations, no EPS, no precision problems, also faster solution.

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

I was trying to solve question D. On codeforces it shows runtime error on test case 1 while same code gives correct output in ideone. Here is my ideone solution link. IDEONE

Here is codeforces solution link Codeforces

PLease help.

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

    This line is incorrect: height[v] = 1 + dfs(node[v][1].first);

    Arrays and vectors in C/C++ are zero-based, so if node[v] has size of one, there is a single element here of index zero, not one. That's undefined behavior and you was lucky enough to get a crash instead of spurious wrong answer. I would recommend you to adapt zero-starting arrays instead of trying to enumerate everything starting with ones.

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

For problem C , I am sorting all the points by the distance from origin and then choosing 3 points closest to origin but it seems to be giving WA 4.This idea will fail if three points are colinear but the reason for WA — 4 mentioned by CF judge is triangle is not empty.I am unable to figure out how this idea fails in situation where 3 points found are not colinear. Here is the wrong code http://codeforces.com/contest/618/submission/15677172 .Thanx in advance.

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

    This is a wrong way of comparing longs. Contract for comparison methods in Java is that they return either zero, or something positive, or either negative (depending on relation). a - b is not ok even for general integers, and here you subtract two longs, get some big result (which may not fit into int) and then truncate it with explicit typecast with data loss. Simply, overflow. You do not have control over sign. Correct way is to use Integer.compare(a, b) or Long.compare(a, b).

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

Congratulations to winners I'm so happy to them

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

When will be T-shirts sent?

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

»
2 years ago, # |
  Vote: I like it +80 Vote: I do not like it
»
22 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Has anyone received a T-Shirt yet? :)

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

    No for here.

    Off-topic: besides Mike pmed me in-site that the Memsql 2.0 Tshirt (which happened 2 years before) is going to be sent, did anyone receive that either?

    • »
      »
      »
      22 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Do you mean MemSQL 2014 T-shirt? I received this 9 months after the contest :)

  • »
    »
    22 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    MikeMirzayanov has not sent me the package's track info. So maybe the T-shirt has not been sent yet.

  • »
    »
    21 month(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Not yet for me.

  • »
    »
    20 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Not yet.

»
19 months ago, # |
  Vote: I like it +41 Vote: I do not like it

finally

»
19 months ago, # |
  Vote: I like it +43 Vote: I do not like it

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

    Why different people get T-shirts in different colors?

    • »
      »
      »
      19 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I guess it's the idea of the organizers.

»
19 months ago, # |
  Vote: I like it +3 Vote: I do not like it

It would be nice if you provide us tracking numbers. Each time I winn a T-shirt I have to call FedEx to confirm the shipment (I don't know why they can't call me :( )