Sunday, May 25, 2014

This week in competitive programming

First, let's return to the previous week's Friday and the Warm-up Round of Yandex.Algorthm 2014 (results, top 5 on the left). Yandex.Algorithm is a tournament that steps a bit away from the usual formats. First, each round is ran using the TCM/Time scoring system which I described in my earlier post about SnarkNews Winter Series. The core of the system is the ability to send each solution either with or without instant feedback, scoring slightly more if you send it without instant feedback, but of course losing it completely if it turns out to be flawed in the end. Second, the selection system for the onsite finals in Berlin is: 25 participants with the best cumulative score in the three elimination stage rounds qualify (details are on the rules page, under heading "Contest structure"). The system is in constrast with the TopCoder system I described in the last week's post: here one can qualify by consistently showing results in top 20ish, whereas TopCoder requires you to have just one very good day and place in the top 12. Of course, in most cases the selection system does not matter that much and the stronger competitors will qualify :)

Now, let's get back to the last week and Tuesday's TopCoder SRM 621 (problems, results, top 5 on the left). The round was tourist's 19th SRM win, and it also brought (a return to) "target" 3000+ rating to three contestants: lyrically, marek.cygan and K.A.D.R. Congratulations Gennady, Kazuhiro, Marek and Iaroslav! I did not take part, so I don't have anything to share about the problems.

And finally, Codeforces Round 248 (problems, results, top 5 on the left) took place on Saturday. Again, I didn't solve the round and can't talk about the problems. The last two problems turned out to be too hard, so while WJMZBMR solved one of them and won in his own league, the others had to fight it out on challenges, and KADR came out on top. Congratulations LiJie (is this the right way to address you?..) and Iaroslav!

Thanks for reading, and see you next week!

Monday, May 19, 2014

This week in competitive programming

The last week had two tournament rounds. On Saturday, TopCoder Open 2014 Round 2A took place (problems, results, top 5 on the left, my screencast). What does "2A" mean? TopCoder has changed the format for the TopCoder Open two years ago. In 2011, the online elimination rounds were structured in a relatively straightforward way: 2000 participants from the qualification round participated in Round 1, and 850 of them advanced to Round 2. Out of 850 participants of Round 2, the best 350 advanced to Round 3. In the same manner, 150 advanced to Round 4, 60 advanced to Round 5, and 24 advanced to the onsite finals.

In other words, in order to qualify for the onsite round one had to place in top 30% of all participants five times. That usually translated to carefully checking and rechecking one's solutions being the most important aspect of the competition for the top algorithmists. Taking risks and performing exceptionally was not rewarded too much.

The format has changed completely starting from 2012. Now 2500 participants from the qualification round (which is now called Round 1A/1B/1C) can participate in three more rounds: 2A, 2B and 2C. In each of those rounds almost 2500 people can participate, and only 50 advance to Round 3 - just the top 2%! If you fail to advance from Round 2A, though, you can participate in the Round 2B, and possibly 2C if still needed. The 150 best competitors determined this way participate in rounds 3A and 3B, with 12 best participants from each round going to the onsite finals - this time the top 8% from each round. The onsite finals have 24 participants, just like in 2011.

There are still five rounds that select 24 best algorithmists from 2000+ participants. In the best case, though, one can participate in just two of them and advance to the onsite round. In my view, such sharp elimination percentages push people to take risks and do their best, and the competition becomes more exciting. My own chances for making the onsite finals have probably reduced, since consistency was always my strength and played nicely with the old system. The new system also allows for more interesting and challenging problems since the cutoff is higher.

The medium problem in this year's Round 2A is quite interesting to reason about: there are 50 wolves on a line segment of length L, i-th wolf starting from point ai and going to point bi. This sounds relatively simple - but the wolves are not allowed to pass each other anywhere except the ends of the segment. So if two wolves want to swap, they have to go either to the leftmost point of the segment, or the rightmost point of the segment. What is the minimum total travel distance they can travel in order for all of them to reach their destinations?

On Sunday, the second Qualification Round of the Russian Code Cup took place (problems, results, top 5 on the left). As I understand, the new Russian Code Cup website ran smoothly this time and the competitors could concentrate on solving the problems - congratulations to the organizers on overcoming all difficulties!

Thanks for reading, and see you next week!

Monday, May 12, 2014

This week in competitive programming

This week had two TopCoder SRMs which brought very good but still very disappointing results for me - two second places :) But I enjoyed solving the problems anyway, and want to share the most interesting ones.

The week started with TopCoder SRM 619 on Monday (problems, results, top 5 on the left, my screencast). Nobody managed to solve the hard problem during the SRM, but it has a very simple and nice problem statement and thus is interesting to solve: consider two sequences of N (up to 100) integers, each integer between 1 and M. We call them similar if it's possible to remove at most two elements from each sequence so that they become equal. How many pairs of similar sequences are there for the given N and M (modulo 109+7)? How would you approach such problem?

TopCoder SRM 620 happened on Saturday (problems, results, top 5 on the left, my screencast). The medium problem turned out to be the most interesting, and produced the most challenges. You were given at most 50 strings with at most 50 characters each, and could sort the strings by any character (keeping the current order when the corresponding character is the same). You needed to come up with a way to obtain the given ordering of the strings from the initial one by zero or more such sort operations. The problem is actually quite simple, but there are many ways to make a wrong step.

Google Code Jam 2014 Round 1C was the last chance to advance to Round 2, and took place on Sunday (problems, results, top 5 on the left). Congratulations to all who advanced - you have just two more rounds before the onsite in Los Angeles!

Any finally, Codeforces Round 245 wrapped up the week (problems, results, top 5 on the left). I did not take part, but have noticed the heated and extensive discussion on the forums - it's always nice to see people take an interest in the problems and their tests beyond simply participating in the contest :)

Thanks for reading, and see you next week!

Monday, May 5, 2014

This week in competitive programming

The week started with the final round of the Kotlin Challenge (problems in Russian, results in Russian, top 5 on the left). The competition took place onsite in the JetBrains office in St Petersburg, and featured just 25 best competitors. In the end, the round was decided on the following problem: you are given an arithmetic expression containings integers, operations "+","-","*","/", parentheses, and at most three occurrences of variable "x". The expression has at most 500 characters. Is there a real value of x that leads to a division by zero in this expression?

On Saturday, Google Code Jam Round 1B gave the second chance to qualify to Round 2 (problems, results, top 5 on the left). I couldn't follow this round, because it was in the middle of ...

Challenge 24 (problems, results, top 5 on the left)! The final 24-hour round for the top 30 teams took place in Budapest from 9am Saturday to 9am Sunday. As usual, the round featured many different types of problems, requiring very diverse skills from the competitors. The winning team, PrecisionScrewdrivers from Poland, found an edge by getting the maximum score of 4000 in problem B which required understanding and improving a large program in a functional language - congratulations! (photo below from the official site)

Here's one of the problems I've enjoyed a lot (problem L): you are given a dump of the OpenStreetMap's road graph of the Earth - about 700 million nodes (id + latitude + longitude) and on the order of one billion edges, two gzipped text files taking about ten gigabytes in total. Then, you're given ten pairs of nodes in this graph and are asked to find any path from the first node to the second one. The time limit is on the order of minutes or even hours - you run this on your own machine and submit the paths. The difficulty of this problem changes greatly depending on the amount of RAM you have. In our case the laptop with most RAM had 8 gigabytes, so we had to work inside that limit. What would you do?


Monday, April 28, 2014

This week in competitive programming

TopCoder SRM 617 took place on Monday (problems, results, top 5 on the left, my screencast). Instead of sharing a problem to solve, I want to share a challenge opportunity that I found in this match. It was in the medium problem, which can be described as: you are given an undirected graph, and want to assign a direction to each edge such that sum of absolute values of in-degree minus out-degree for each vertex is as small as possible. The solution I challenged went like this: let's assign a random direction to each edge, and then repeatedly reverse an arbitrary edge that would reduce the cost function. Then, we repeat the whole process 500 times and pick the best result. Can you come up with a challenge case (the graph has at most 50 vertices and at most 1000 edges)?

TopCoder SRM 618 took place on Friday (problems, results, top 5 on the left), at 5am Moscow time. This was too much, and I've skipped this one.

Google Code Jam Round 1A took place on Saturday (problems, results, top 5 on the left). I was the author of the third problem, which I like a lot, and encourage you to try solving it if you haven't already - the Code Jam website allows you to submit your solutions even if you hadn't participated in the actual contest. The problem basically gave a buggy (but reasonably good) algorithm to randomly shuffle an array, and you had to determine whether the buggy or the correct algorithm was used just by looking at the generated array.

TopCoder Open 2014 Round 1C took place later on Saturday (problems, results, top 5 on the left), with the field getting a bit weaker with most top competitors having already qualified for Round 2, and the problems were made correspondingly easier - so easy, in fact, that the coder with handle 'Min,lu' has taken the third place in the TopCoder record book by solving three problems correctly and spending just 10 minutes in total!

Those who already qualified could take part in Parallel Round 1C which used the same problems (top 5 on the left). The winner 'fetetriste' solved all three problems while spending less than 9 minutes, so he would've also get a high spot on the above record table - but the parallel round was unofficial and its results won't appear in the stats database.

And finally, Codeforces Round 243 happened on Sunday (problems, results, top 5 on the left, my screencast). The round had some nice problems, out of which the following was the nicest - if a bit well-known - one: you are given 100000 points on the plane. How many squares are there with sides parallel to the coordinate axes and all four vertices in the given points?

Thanks for reading, and see you next week!

Monday, April 21, 2014

This week in competitive programming

On Wednesday, Codeforces ran a normal round with an unusual title: Russian Code Cup 2014 Warmup (problems, results, top 5 on the left) with problems from the organizers of Russian Code Cup 2014, which we'll talk about below. I didn't take part, so I can only share a funny Swistakk's quote with you: "tourist had so much luck in this contest :P! Egor on 2nd place got TLE on E, because TL was very tight and flashmt on also 2nd place got TLE on A, because of endl's instead of \n and they will easily win if it weren't for those unlucky TLEs!" As the saying goes, fortune favours the bold!

Early on Saturday, the first qualification round of the Russian Code Cup 2014 took place (problems, results, top 5 on the left, my screencast). Russian Code Cup is a big competition with problems in Russian ran by Mail.Ru and ITMO. The round had quite a lot of technical issues, which was a pity since the problems themselves were nice.

Later on Saturday, Round 1B of the TopCoder Open took place (problems, results, top 5 on the left). The round saw many veterans at the top of the standings: krijgertje participated for the first time since TCO12, SnapDragon, meret and peter50216 participated for the first time since TCO13 - and they're all in top 7!

At the same time, people who have already qualified could try the same problems in Parallel Round 1B (top 5 on the left, my screencast). The problems had easy-to-understand statements but required some creativity to solve. Here's the medium difficulty one: you are given a 16x16 grid where some cells contain wolves, some cells contain sheep, and some are empty. You are allowed to build infinitely long vertical and horizontal walls along grid boundaries. What is the smallest number of walls needed to separate the sheep from the wolves?

Finally, on Sunday, the last round of this year's Open Cup took place (results, top 5 on the left). It had fewer participating teams than usual, but at the same time the teams from China showed impressive results, reminding that we shouldn't forget about them when making predictions for the ACM ICPC World Finals.

Here are the overall Open Cup standings. The top has a nice mix of veteran teams, like my team or the XZ team, current ACM ICPC competitors like SPb SU 4 and Moscow SU Tapirs, and the winning team tourist in a class of himself :)

Thanks for reading, and see you next week!

Monday, April 14, 2014

This week in competitive programming

This week was so busy that I didn't have time to solve programming contests, so here's just a quick summary of their results.

TopCoder SRM 616 took place on Thursday (problems, results, top 5 on the left).

The first round of TopCoder Open 2014, Round 1A, took place on Saturday (problems, results, top 5 on the left).

However, top 250 by rating who have participated in SRMs in 2014 were automatically advanced to Round 2, and there was a special Parallel Round where those could compete (same problems as Round 1A, top 5 on the left). Surprisingly, the top fives of both rounds are comparable.

Google Code Jam 2014 Qualification Round ran for 27 hours between Friday and Saturday (problems, results, top 5 on the left).

And finally, the 13th round of the Open Cup took place on Sunday (results, top 5 on the left).

Thanks for reading, and check back next week for a hopefully more informative report!