By Lewin, 5 years ago,

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.

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

• +707

 » 5 years ago, # |   +17 Will it be rated round?
•  » » 5 years ago, # ^ |   +34 Yes, it will be a rated round.
•  » » » 5 years ago, # ^ |   +8 Is it gonna be 5 problems in 2 hours?
•  » » » » 5 years ago, # ^ |   +55 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.
•  » » » » » 5 years ago, # ^ | ← Rev. 2 →   +29 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?
•  » » » » » » 5 years ago, # ^ |   +54 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.
•  » » 5 years ago, # ^ |   +56 I cant understand the downvotes, i had a query and i asked it.
•  » » » 5 years ago, # ^ |   -7 This thing happened to me a few days earlier as well! I don't why this happens.
 » 5 years ago, # |   +7 Hope to have Some Short & Easy to Understandable Problem Statement in this Contest . Good Luck to All & Me.
•  » » 5 years ago, # ^ |   +16 Short-and-easy-to-understand statement means hard-to-solve problem...
•  » » » 5 years ago, # ^ |   +11 haha
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +338
•  » » » » » 5 years ago, # ^ | ← Rev. 4 →   -26
 » 5 years ago, # |   +56 Let it be combined DIV 1 and DIV 2. It will be more interesting and challenging for the DIV 2 coders as well.
•  » » 5 years ago, # ^ |   0 your wish come true :D
 » 5 years ago, # |   +78 My first reaction was, Lewin is the setter, the problems will be awesome :D
 » 5 years ago, # |   -47 And there will be a lot div 1 contestant participating in div 2 to get prizes :'(
 » 5 years ago, # | ← Rev. 3 →   +46 tourist gonna play everyday PS4 :)
•  » » 5 years ago, # ^ | ← Rev. 2 →   -7 oh, that's really disturbing here.. (like me)
 » 5 years ago, # |   +5 Prizes and gifts only for Div1?
•  » » 5 years ago, # ^ |   +117 We are planning to merge divisions, it will be common problemset with 7 problem. Everybody can win prizes!
•  » » » 5 years ago, # ^ |   +28 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?
•  » » 5 years ago, # ^ |   0 Nope. See 51-500 get shirts on random basis. So, try your best, you can be lucky.
 » 5 years ago, # |   +73 3-5 places = the best prize
 » 5 years ago, # | ← Rev. 2 →   +11 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
•  » » 5 years ago, # ^ |   +52 Win Playstation 4 so you can use your computer less and make your parents happy :)
•  » » » 5 years ago, # ^ |   +31 It is bigger probability to go to some shop and steal PS4 than win some prize on the official contest :PEven I haven't got t-shirts which I won before 8 months :)
•  » » » 5 years ago, # ^ |   +5 Prizes and gifts only for Div1?
 » 5 years ago, # | ← Rev. 2 →   0 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.
 » 5 years ago, # |   +38 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*
•  » » 5 years ago, # ^ | ← Rev. 2 →   +24 Never tried Xbox, but PS4's joysticks are just awesome!)
•  » » 5 years ago, # ^ |   +97
•  » » » 5 years ago, # ^ |   -27
•  » » » » 5 years ago, # ^ |   +71 What's a disk, do I download it?
 » 5 years ago, # |   0 I loved your last round specially that problem about combinatorics !!
 » 5 years ago, # |   +45 What if tourist preferred Xbox than PS4?
•  » » 5 years ago, # ^ |   +27 what if he already has both from previous contest wins?
•  » » 5 years ago, # ^ |   +20 I think there should be an option for every winner to take the prize of a beaten one if they wish.
•  » » 5 years ago, # ^ |   +14 I guess in this case he can make some incorrect hacks or extra submits.
•  » » » 5 years ago, # ^ |   -24 What if he over-mis-hack and fall to rank 3?
•  » » 5 years ago, # ^ |   +5 Is that why tourist didn't participate?
 » 5 years ago, # |   -17 memes)
 » 5 years ago, # |   0 can i join if my age is less than 18 (i am in school not university) ?
•  » » 5 years ago, # ^ |   0 They will never choose you even if you were 18++.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +3 Why on earth wouldn't you be able to join?
•  » » » 5 years ago, # ^ |   -14 "Note, Wunder Fund is a Russian-speaking company" -- did you noticed that?
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +11 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.
•  » » » » » 5 years ago, # ^ |   -27 well, if you didn't mean the company, then you were ambiguously so funny.
•  » » » » 5 years ago, # ^ |   +2 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.
•  » » 5 years ago, # ^ |   0 Reason is there ,and here
•  » » 5 years ago, # ^ |   +1 sure！
 » 5 years ago, # |   +58 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
 » 5 years ago, # |   -42 Легкий рейтинг++ для Div. 2)
 » 5 years ago, # |   0 Why not Nintendo！？ Though I think it's impossible for me to get one：）
 » 5 years ago, # |   -37 В описание приза есть опечатка, там написано "сувениврные футболки Wunder Fund".
•  » » 5 years ago, # ^ |   0 write English
•  » » 5 years ago, # ^ |   +3 that's right :))
 » 5 years ago, # | ← Rev. 3 →   0 so there's a high probability that dude at rank #51 won't get a t-shirt....
•  » » 5 years ago, # ^ |   +54 Higher than for rank #600 so I guess it's still optimal to fight for a good place.
 » 5 years ago, # |   -77 What about rooms? Will they also be combined? Please say no!
•  » » 5 years ago, # ^ |   +34 No. All rooms aren't combined into a huge room :P
•  » » » 5 years ago, # ^ |   +9 I think he meant will div.2 participants can be in same room with div.1 participants.
•  » » » » 5 years ago, # ^ |   +6 Exactly!
•  » » 5 years ago, # ^ | ← Rev. 4 →   +57 Please say no!Why?Hacked is better than failed system tests.
•  » » » 5 years ago, # ^ |   +84 If your solusion doesn't use hashing)
•  » » » 5 years ago, # ^ |   +8 Because there will be more probability of hacking div 2 coder's solution than div 1 coder's solution.
 » 5 years ago, # |   +77 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.
•  » » 5 years ago, # ^ |   +47 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!
•  » » » 5 years ago, # ^ |   +20 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.
 » 5 years ago, # | ← Rev. 3 →   -31 it will be a rated contest
•  » » 5 years ago, # ^ |   -27 it's a good rated contest
•  » » » 5 years ago, # ^ |   -19 yeah
 » 5 years ago, # |   -30 rated contest
•  » » 5 years ago, # ^ |   -23 good rated contest
•  » » » 5 years ago, # ^ |   -31 yeah
•  » » » » 5 years ago, # ^ |   -16
 » 5 years ago, # |   -25 The contest is prepared by Lewin ==> the contest is greatfull :DGood luck!
•  » » 5 years ago, # ^ |   -15 Hir shodi :D
•  » » 5 years ago, # ^ | ← Rev. 2 →   +2 the comment is written by amsen ==> the comment will get lots of downvotes :D
 » 5 years ago, # |   0 I believe you guys forgot to send an email announcement.
•  » » 5 years ago, # ^ |   -8 Nice, I got it right as soon as I posted this comment.
 » 5 years ago, # |   0 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.*^_^*
 » 5 years ago, # |   0 oh lots of contests these days !!ENJOY !
 » 5 years ago, # |   -8 Will the problems be sorted according to difficulty?
•  » » 5 years ago, # ^ |   -12 It depends on score distribution which will be announced just before contest
 » 5 years ago, # |   0 why is it so late? I thought it is always at 2pm(GMT)
 » 5 years ago, # |   -8 so combined round and only 2 hours. pretty interesting.
 » 5 years ago, # |   +22 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.
 » 5 years ago, # |   -7 Is the number of problems and duration of the contest finalized?
 » 5 years ago, # |   +53 When you're trying to win all prizes
•  » » 5 years ago, # ^ |   0 iam sure nobody can't win all prizes !!! but trying is good :))
•  » » 5 years ago, # ^ |   -10 I don't want to win Prizes . I just want to Solve Problems .
•  » » 5 years ago, # ^ |   0 Gaming?...Why???
 » 5 years ago, # |   -16 Why so much hate for trunghai95? Whatever he comments gets down voted so brutally :p Or, am I gonna get it now? :/
 » 5 years ago, # |   0 will the rating system be changed (because it's div 1+ div2) or will it stay the same???
 » 5 years ago, # |   +1 6699 registered! Interesting number (=
•  » » 5 years ago, # ^ |   0 Indeed.
 » 5 years ago, # |   +2 7 rpoblems and only 2 hours.
 » 5 years ago, # |   +41 CF running slow for me. Not a good sign.
•  » » 5 years ago, # ^ |   +1 Yeah, another delay... I think it's good sign.
•  » » 5 years ago, # ^ |   0 damn. me too
•  » » 5 years ago, # ^ |   0 me 2, i've lost 5 minutes to connect to CF.
 » 5 years ago, # |   -28 Why has registration been closed? Please open registration — the competition hasn't even started yet.
 » 5 years ago, # |   0 Its saying i am not allowed to view the contest.
 » 5 years ago, # |   +57 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 using namespace std; int main(int argc, char* argv[]) { registerGen(argc, argv, 1); vector 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; } 
•  » » 5 years ago, # ^ |   0 This is a fair and effective process. I like it.
•  » » 5 years ago, # ^ |   +18 I completely forgot about the T-shirts :D. This is an important milestone for me: not caring about prices and competing truly only for competing.
•  » » 5 years ago, # ^ |   +74 4 people placed 499. 4 * 2614 = 10456.T-Shirt Random Winners: 498 218 125 86 452 496 145 405 99 412 260 382 449 461 240 131 337 116 210 249 393 488 457 447 266 416 370 386 497 58 197 104 478 165 254 251 374 181 111 307 132 471 360 124 299 229 425 492 63 363
•  » » » 5 years ago, # ^ |   +10 Exactly! Thanks.
•  » » » » 5 years ago, # ^ |   0 MikeMirzayanov, is the above list the final list of winning ranks?
•  » » » 5 years ago, # ^ |   +34 498 AtomRush218 JavaInTheSouth125 dragoon86 alex20030190452 gangsterveggies496 NikitaMikhaylov145 IlyaLos405 wu6shen99 teleport412 Vetand260 Andrei1998382 slava.sh449 wmx16835461 og.kostya240 Danlark131 namai337 fraud116 I_love_tigersugar210 NelsonMondialu249 BaconLi393 shubh09488 avv457 duyboy135447 Petruchcho266 gut416 KevinTan370 KArs386 spentplaying497 Bayan58 andrew.volchek197 kreker104 Shik478 saurabhsuniljain165 Fedosik254 RostVel251 luke0201374 Inspiration181 __math111 DamianS307 xzj1997132 Tzn-40471 cchao360 PrashantM124 GinghouLuk299 mirceadino229 ATofighi425 FallenTurret492 andwho63 Nezzar363 Morphy
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   +36 I'm placed 425th too (and so are yukihana0416 + gsa93). Will all 4 of us get a T-Shirt?
•  » » » » 5 years ago, # ^ |   +5 I'm placed 393 too.
•  » » » » 5 years ago, # ^ |   0 I am placed 492th too.
•  » » 5 years ago, # ^ |   +26 But some places are not exist. For example 452(or 500). It's good?
•  » » 5 years ago, # ^ |   +15 I think you need to have the array holding the handles of users instead of the ranks because many ranks do not exist and many participants share the same rank.
•  » » » 5 years ago, # ^ |   +18 When this happened previously, they gave tshirts to all of them. Link
 » 5 years ago, # |   +57 Today: funny CF handles![user:http://codeforces.com/profile/CantGetAnyACWhyAmISoWeak]Doesn't seem to be true, considering he's somewhere above 60th place now.
•  » » 5 years ago, # ^ |   +10 CanJustGetSomeACWhyAmISuperWeak
•  » » » 5 years ago, # ^ |   +8 CanJustGetSomeACWhyAmINotTourist
 » 5 years ago, # |   +2 short and nice questions...enjoyed solving :D
 » 5 years ago, # |   +56 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.
•  » » 5 years ago, # ^ |   +5 if X < Y then answer is X * (vertices in longest path) + Y * (remaining vertices). Else answer = Y * (vertices — 1)Is this correct ?
•  » » » 5 years ago, # ^ |   +5 Incorrect.3 2 11 21 3Write answer — 3 (1->2->3)
•  » » » » 5 years ago, # ^ |   +5 got it, thanks.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
•  » » » » 5 years ago, # ^ |   0 yeah got it, thanks!
•  » » » 5 years ago, # ^ |   0 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)".
•  » » » 5 years ago, # ^ |   -8 For X2->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.
•  » » » » 5 years ago, # ^ |   0 I got my mistake, any way thanks
•  » » 5 years ago, # ^ |   0 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
•  » » » 5 years ago, # ^ |   +1 But you've found your mistake, I still can't:D
•  » » 5 years ago, # ^ |   +5 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
 » 5 years ago, # |   +21 Imho, 2 hours is not enough for 7 tasks. Besides that, nice tasks :)
•  » » 5 years ago, # ^ |   0 You have passed pretests in only three problems) And no one have solved G. But tasks were beautiful, I agree with you
 » 5 years ago, # | ← Rev. 2 →   +2 What is the hacking testcase of Problem C ?
•  » » 5 years ago, # ^ |   0 For my solution it was: 4 0 0 2 0 1 0 1 2
•  » » 5 years ago, # ^ |   0 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
 » 5 years ago, # |   +15 Great to see eatmore performing again.
 » 5 years ago, # |   0 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/15662186Thanks in advance.
•  » » 5 years ago, # ^ |   0 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.
•  » » » 5 years ago, # ^ |   0 I believe this still gets TLE.
•  » » » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
•  » » » » » 5 years ago, # ^ |   0 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.
•  » » » » » » 5 years ago, # ^ |   0 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.
 » 5 years ago, # |   +8 Okay please tell me how to solve D. I understand that if x=y answer will be (n-1)*y or ((n-2)*y+x). Whats wrong in this?
•  » » 5 years ago, # ^ | ← Rev. 2 →   +11 It's not diameter. Here's a tree.1 2 1 3 1 4 4 54 6
•  » » » 5 years ago, # ^ |   0 By diameter, I mean maximum distance between any two nodes. Am I wrong in this?
•  » » » » 5 years ago, # ^ |   +3 Yes, you are wrong. Look at the above example.
•  » » 5 years ago, # ^ |   +3 Not a diameter, you need to split the tree into lines such that the sum of lengthes is maximal.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +8 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.
•  » » » 5 years ago, # ^ |   +3 n cannot be 1. (2 ≤ n ≤ 200 000, 1 ≤ x, y ≤ 109)
•  » » » 5 years ago, # ^ |   -10 n is at least 2; read problem statement more carefully.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +2 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.
•  » » » » 5 years ago, # ^ |   +7 It depends what do you mean that path is. For example6 1 21 22 34 55 62 5has 4 leaves, but you can use 4 of its 5 paths (all except 2 5).
•  » » » » » 5 years ago, # ^ |   +3 Thank you, that was illuminating :) Now I know my mistake.
•  » » » 5 years ago, # ^ |   0 Got my mistake.
•  » » 5 years ago, # ^ |   +3 you could add to path not only diameter. Also you could add some more edges from tree.
 » 5 years ago, # |   +4 I'm good at geometry：（ I think Problem C can be solved by PolarAngleSort，but I failed on test4.
•  » » 5 years ago, # ^ | ← Rev. 2 →   +5 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.
•  » » 5 years ago, # ^ |   +6 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.
 » 5 years ago, # |   +3 my submission before 5 seconds did not go into submission queue.. T.T
•  » » 5 years ago, # ^ |   0 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 :)
•  » » » 5 years ago, # ^ |   0 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 :)
•  » » » » 5 years ago, # ^ | ← Rev. 3 →   0 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!!
•  » » » » » 5 years ago, # ^ | ← Rev. 2 →   +3 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 task2) No penalty for AC submissions that failed system testing
•  » » » » » 5 years ago, # ^ |   +5 If it's the penalty of problem AC score and not of total score, it's correct.
•  » » 5 years ago, # ^ |   +1 I submitted before 10 sec the problem CIt 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 :(
•  » » » 5 years ago, # ^ |   0 About same case for my Problem D where I forgot to comment out freopen -_-
 » 5 years ago, # |   0 How to find minimum area triangle in O^2?
 » 5 years ago, # |   0 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?
•  » » 5 years ago, # ^ |   0 You could have just simulated the process in O(N) . (Look Here)[http://codeforces.com/contest/618/submission/15651613]
 » 5 years ago, # |   +2 one silly mistake and rank moved back a 1000 places >_< .
 » 5 years ago, # |   +16 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...
•  » » 5 years ago, # ^ |   +8 wow.. it's amazing that the code above could pass pretests
 » 5 years ago, # |   +77 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?
•  » » 5 years ago, # ^ |   +21 Sorry for my ignorance . But isn't it P!=NP ??
 » 5 years ago, # |   +2 Problem C — Time limit exceeded on test 84... :(
 » 5 years ago, # | ← Rev. 2 →   0 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
•  » » 5 years ago, # ^ |   +3 Seems to me like you sent wrong link.
•  » » » 5 years ago, # ^ |   +3 Oh yeah, my bad. Thanks, I fixed it.
•  » » » » 5 years ago, # ^ |   +3 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)
•  » » 5 years ago, # ^ |   -12 No "return 0;" in main.
•  » » » 5 years ago, # ^ |   0 Yeah, that is why he he/she passed previous 84 tests:D
•  » » » 5 years ago, # ^ |   +11 It's allowed in C/C++, compiler will treat that as return 0;. But that's behavior specific for the main function only.
•  » » 5 years ago, # ^ | ← Rev. 4 →   +3 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.
 » 5 years ago, # |   +6 A solution to the hard case of D can be found here:http://www.austms.org.au/Publ/Jamsb/V44P2/pdf/1761.pdf
 » 5 years ago, # |   +3 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.
•  » » 5 years ago, # ^ |   0 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.
 » 5 years ago, # |   +19 All problems are very excellent. Thanks to Wunder Fund Company.:)
•  » » 5 years ago, # ^ |   +17 And thanks to Lewin.
 » 5 years ago, # |   +9 chill bro, it's A and it's not easy to hack this guy. Why would someone try so hard on A?
•  » » 5 years ago, # ^ |   +3 someone wanted to lose rating...
 » 5 years ago, # | ← Rev. 2 →   0 Wow, so many fails on problem C.
 » 5 years ago, # |   +3 RomaWhite, maybe, is the unluckiest human in the whole world now... 1 point form XBox One :(
•  » » 5 years ago, # ^ |   0 Testing is not finished yet, so he could finish on worse place.
•  » » » 5 years ago, # ^ |   0 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!
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 on the other hand, Wunder Fund are lucky because that point avoided the headache to them deciding who will win the XboxUPD: now both dropped one place to 3rd and 4th so no one is lucky and no one is unlucky
•  » » » 5 years ago, # ^ |   0 That was my mistake, I am so sorry for my previous comment. But now Um_nik is in 6 points from XBox One)
•  » » 5 years ago, # ^ |   0 And now he won't...(rank 4)
 » 5 years ago, # |   0 Interesting that this solution that doesn't map the indices passes the tests: http://codeforces.com/contest/618/submission/15664708.
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
•  » » » 5 years ago, # ^ |   0 You are completely right.
 » 5 years ago, # |   +4 connor: blue, extremely high. His previous results aren't that great. Seems suspicious.
•  » » 5 years ago, # ^ |   +11 See this one's contests history: xuanhien070594
•  » » 5 years ago, # ^ |   -15 Take it easy! Just think like, he is better than you. maybe he doesn't always take the contests seriously like you?
•  » » » 5 years ago, # ^ |   +3 A lot of assumptions for an unrated user!
•  » » » » 5 years ago, # ^ |   -24 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
 » 5 years ago, # |   0 Can I see my ranking considering only div. 2 participants?
 » 5 years ago, # |   0 Hello guys,can someone please give me any hint on how could i solve problem B? Cheers
 » 5 years ago, # | ← Rev. 2 →   0 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
•  » » 5 years ago, # ^ |   0 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.
•  » » » 5 years ago, # ^ |   0 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).
•  » » 5 years ago, # ^ | ← Rev. 4 →   0 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): Find valid triangle: take first two points and iterate for others, first one that is not on the same line = got valid triangle. 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".
•  » » » 5 years ago, # ^ |   0 This solution is wrong when between first two points exist the thrid one and all three are colinear.
•  » » » » 5 years ago, # ^ |   0 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".
•  » » » » 5 years ago, # ^ |   0 All N points are never collinear . It's mentioned in the statement .
•  » » » 5 years ago, # ^ |   0 I thought about O(N log N) : I sort the points by distance from the first point.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
•  » » 5 years ago, # ^ |   +3 i did the same it was accepted , the approach is correct http://codeforces.com/contest/618/submission/15660749
 » 5 years ago, # |   0 You forget about overflow and you get Wrong answer on test 93 :/
 » 5 years ago, # |   -11 round is rated or unrated ????
•  » » 5 years ago, # ^ |   0 It's rated. Look in the first comments. http://codeforces.com/blog/entry/23084?#comment-274938
•  » » » 5 years ago, # ^ |   0 but rating has not yet been updated
•  » » » » 5 years ago, # ^ |   0 System test still going. If I were you, I wouldn't expect update sooner than in half of an hour)
 » 5 years ago, # |   -21
•  » » 5 years ago, # ^ | ← Rev. 2 →   +6 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.
 » 5 years ago, # |   0 Int fu**ked me on test case "93" problem C
•  » » 5 years ago, # ^ |   0 Same here ! Submitted C thrice ( once after getting hacked ). All that for a WA because of overflow :(
 » 5 years ago, # |   +46 And congratulations for 51st place to: FatalEagle!
•  » » 5 years ago, # ^ | ← Rev. 2 →   +148 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!
•  » » » 5 years ago, # ^ |   +174 For the past 5 minutes I was watching aropan's submission too.Thanks for the congratations.
•  » » 5 years ago, # ^ |   +33 FatalEagle be like
 » 5 years ago, # | ← Rev. 2 →   +74 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 :-(
•  » » 5 years ago, # ^ |   0 lol
•  » » 5 years ago, # ^ |   0 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.
•  » » 5 years ago, # ^ |   0 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.
 » 5 years ago, # |   0 That's why I like TC SRM the most :( no problem for int or long long . WA at 93th whatever my logic was right. I should be happy :)
•  » » 5 years ago, # ^ |   +2 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.
•  » » » 5 years ago, # ^ | ← Rev. 2 →   +5 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 :)
 » 5 years ago, # |   0 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.
•  » » 5 years ago, # ^ |   +1 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.
•  » » » 5 years ago, # ^ |   0 But in that case, whichever triangle you form will have zero area. That is not valid.
•  » » » » 5 years ago, # ^ |   +1 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.
•  » » » » » 5 years ago, # ^ |   0 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.
•  » » » » » » 5 years ago, # ^ |   +1 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.
•  » » » » » » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
•  » » » » » » 5 years ago, # ^ |   0 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 .
 » 5 years ago, # |   0 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 .
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 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 .
•  » » 5 years ago, # ^ | ← Rev. 2 →   +13 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
•  » » 5 years ago, # ^ |   0 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.
•  » » » 5 years ago, # ^ |   0 Thanks i got AC
•  » » 5 years ago, # ^ |   0 The approach is broadly correct. I just implemented it to test: 15667843. However: 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). points can be on the same line that is neither horizontal nor vertical; this case should be recognized and skipped.
 » 5 years ago, # |   +68 When the T-shirts will be announced?
 » 5 years ago, # |   0 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 ?
•  » » 5 years ago, # ^ |   +5 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.
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 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.
 » 5 years ago, # | ← Rev. 3 →   0 good contest
 » 5 years ago, # |   +67 Problems with awesome quality. Nice, Lewin. And for me drawings in E were extremely helpful. Thanks for a round.
 » 5 years ago, # |   0 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
•  » » 5 years ago, # ^ | ← Rev. 2 →   0 Just use scanf instead of cin ,your code is fine .
•  » » » 5 years ago, # ^ |   0 you are right! In efficiency,is there a lot of difference between cin and scan? how many milisec?
•  » » » » 5 years ago, # ^ |   0 Difference isn't big but you must write ios_base::sync_with_stdio(0) when using iostream (cin, cout).
•  » » » » 5 years ago, # ^ |   0 Your code using scanf take only 93 ms.
 » 5 years ago, # |   +2 Finally returned my yellow, thanks for the round! And like it if your first submission for problem D was a diameter too!
•  » » 5 years ago, # ^ |   +5 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.
 » 5 years ago, # |   0 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
•  » » 5 years ago, # ^ |   +3 Precision Wrong dmax 15672460
•  » » » 5 years ago, # ^ |   0 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.
•  » » » » 5 years ago, # ^ |   0 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.
 » 5 years ago, # |   0 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
•  » » 5 years ago, # ^ | ← Rev. 3 →   +3 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.
•  » » 5 years ago, # ^ | ← Rev. 3 →   +9 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.
 » 5 years ago, # | ← Rev. 2 →   0 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. IDEONEHere is codeforces solution link Codeforces PLease help.
•  » » 5 years ago, # ^ |   +23 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.
 » 5 years ago, # | ← Rev. 3 →   0 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.
•  » » 5 years ago, # ^ |   +11 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).
•  » » » 5 years ago, # ^ |   0 Thank You !
 » 5 years ago, # |   +2 Congratulations to winners I'm so happy to them
 » 5 years ago, # |   +14 When will be T-shirts sent?
 » 5 years ago, # |   +8
 » 5 years ago, # |   +80 I have great news! WunderFund approved additional 43 t-shirts for all participants shared the same winner places! So random t-shirts will be sent to: 58 andrew.volchek 63 Nezzar 86 alex20030190 99 teleport 104 Shik 111 DamianS 116 I_love_tigersugar 124 GinghouLuk 125 dragoon 131 namai 132 Tzn-40 145 IlyaLos 165 Fedosik 181 InDaBag __math 197 kreker 210 NelsonMondialu 218 JavaInTheSouth 229 ATofighi 240 Danlark 249 BaconLi 251 luke0201 savinov Batman 254 RostVel 260 Andrei1998 266 gut 299 aekt HidenoriS mirceadino 307 xzj1997 337 randomguy1 fraud 360 jeremy624lolz PrashantM 363 sajo Morphy ahmed_aly stjepanp 370 jklepec Rusu KArs 374 Inspiration -skyline- 382 sskolot slava.sh 386 shiva_r31 zloyplace35 spentplaying 393 shubh09 rzmn 405 wu6shen 412 yum Vetand J_X 416 _Rampage_ KevinTan winnfield 425 gsa93 yukihana0416 FallenTurret fleimgruber 447 Petruchcho 449 wmx16835 452 Malinovsky239 venkat82 gangsterveggies 457 duyboy135 461 techwiz911 og.kostya One_touch_finish Mixf daivik.the.great 471 vishalkarve15 cchao Elise femsub Ibro 478 DenXX mainstring saurabhsuniljain Egor.Lifar Glaceon08 space69 488 avv 492 turmoil andwho 496 NikitaMikhaylov 497 Bayan 498 kondranin AtomRush szszsz I_lost_myself
•  » » 5 years ago, # ^ | ← Rev. 2 →   +33 Finally I'm lucky enough to be randomly selected to win a t-shirt. Thanks! :)
•  » » » 5 years ago, # ^ |   +12 For the first time ever, I have won a T-shirt from a CodeForces contest! Feels great, I hope there will be many more to come. :)
•  » » 5 years ago, # ^ |   0 wheeeee
•  » » 5 years ago, # ^ |   0 oh~ so sad...
•  » » 5 years ago, # ^ |   +5 MikeMirzayanov Any updates on T-shirts ? I am from India.
 » 5 years ago, # |   +3 Has anyone received a T-Shirt yet? :)
•  » » 5 years ago, # ^ | ← Rev. 3 →   0 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?
•  » » » 5 years ago, # ^ |   0 Do you mean MemSQL 2014 T-shirt? I received this 9 months after the contest :)
•  » » » » 5 years ago, # ^ |   0
•  » » 5 years ago, # ^ |   0 MikeMirzayanov has not sent me the package's track info. So maybe the T-shirt has not been sent yet.
•  » » 5 years ago, # ^ |   0 Not yet for me.
•  » » 5 years ago, # ^ |   0 Not yet.
 » 5 years ago, # |   +41 finally
•  » » 5 years ago, # ^ |   +15 Not yet received.
 » 5 years ago, # |   +43
•  » » 5 years ago, # ^ |   +8 Why different people get T-shirts in different colors?
•  » » » 5 years ago, # ^ |   0 I guess it's the idea of the organizers.
 » 5 years ago, # |   +3 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 :( )