Sunday, January 08, 2012

SRM 451 - BrickPuzzle - Part 1

Remember that time I said that I would be making editorials for topcoder problems that lack official editorials? Remember how I stopped doing that after the first such time I did that?

Here is another problem I made for TopCoder that does not have an official editorial. It is a div 1 1000 (oooh).

BrickPuzzle
Link to problem statement

So you have infinitely many tetraominoes of the following shapes:


We want to place them in a grid with black and white squares in such a way that all white squares are covered by a tetraomino. Black squares do not necessarily have to be covered but can be covered if you need to. Tetraominoes you place must be aligned to the grid, cannot overlap and must lie completely inside the grid. You cannot rotate the tetraominoes , so they must be placed in the same way as the figure. Use as few tetraominoes as possible.



The maximum dimensions for the grid are 22x22. If it is impossible, return -1.


The backstory
You know what? Writing problems for Topcoder is difficult. Do not get me wrong, I am not saying that it is very hard. I am saying that it is horribly hard and makes your head melt. Right now I am still trying to think of problems that I needed to think of exactly the moment after the last SRM I wrote ended.

Sometimes I think of a problem I find in real life and try to turn it into TopCoder juicem this is the honest way to do it and is rarely useful. The dishonest way is to first think of a cool idea for a solution to a problem and then find some sort of problem that fits that idea of a solution.

What happened here is that I figured, that bitmask dp and similar are based on encoding a number as a bit mask and then using that number as a key. The idea was , why not think of a problem that does the same but instead of bitmasks, uses another number format?

The result was the problem that eventually became FourBlocks. An easy typical dp problem with the twist that the dimensions (22x22) do not allow the typical bitmask dp approach. For some reason I thought that was a good idea for a division 1 medium. When I showed this problem to Ivan Metelsky, he said that I should change the maximum dimension to 10x10 (Yes, really). He predicted (quite correctly) that even with 10x10 it would be a problem difficult enough for division 1 500, because a lot of people would be lame enough to use a greedy solution even though the constraints make it very easy to use dynamic programming.

I still wanted to use my original idea, so I saved it up for later. I figured that if I instead of using it in a typical problem, I used it in a less typical setting and included further implementation complications, it would actually be a div1 hard (Division 1 hards are to me the holy grail of problem setting, because they are impossible to think of, and once you have one, thinking of the rest of the SRM is not very hard, so you can ensure to take 500 dollars home).

Thus in the next SRM, I used BrickPuzzle. It turned out to be very difficult. I mean, nobody solved it. As such it is a failure. Every problem that does not get solved during a match is a failure. It still makes an interesting topic. I really love this problem and consider it a homage to dynamic programming. I also think that if you learn this problem you will finally understand the cons and pros of iterative dynamic programming and recursion + memoization.


This finishes part 1. In the next part I will hopefully write an editorial. I plan that part to be finished tomorrow.

Saturday, January 07, 2012

About The 5 most annoying things about sports (To non sports fans)

I am sorry, but I cannot share links easily thanks to google reader and feedly, so I will have to post this one manually. It deserves to be shared.

cracked.com - The 5 Most Annoying Things About Sports (To Non Sports Fans)'

Thank you cracked, for expressing my feelings in the perfect manner once again.

Wednesday, January 04, 2012

Glad I am not the world's best programmer

Update: The incredibly misleading name "Facebook hacker cup" makes Bolivian newspapers fail: Facebook busca al mejor hacker del planeta

Just read: Are You The World’s Best Programmer? Compete In Facebook’s 2012 Hacker Cup

Last year I found a TopCoder thread about something called a hacker cup. But the link to explanation about its rules was a facebook page. And you know what I get when I try to open a facebook page?



Yeah, I had to register to facebook just to see info about that hacker cup thing last year, so I just didn't give it much importance and continued reading other threads.

Some time later, that thread exploded. Wow it was such an interesting read. Facebook managed to compress all possible horror stories about programming contests in a single qualification round... Generic problems, site glitches, bad test data, difficult to use interface...

The many issues with the so-called hacker cup apparently got quite an echo: Facebook hacker cup: Resounding failure.

Apparently it eventually gained some stability and the cup could continue. Which lead us to the best headline of 2011: Google Employee wins Facebook Hacker Cup. Hah. Later though, google got a taste of their own when the code jam first and second place went to TopCoder admins...

Also hilarious were the many reports of people offering money for help in the hacker cup. Yes, really it happened. Too bad I can't find the relevant links right now.

I won't participate in the hacker round. The prizes:

Of course! $5,000 USD and title as world champion to the top hacker, $2,000 for second place, $1,000 for third, and $100 for fourth through 25th. Awesome t-shirts for the top 100 hackers coming out of the second online round.

Are quite underwhelming and to me not out-weight the cons of creating a facebook account. I just look forward to what fun events will happen this year in relation to it. I am just glad I am not the world's best programmer.

To anyone who does not know much about programming contests, I would say things like google's code jam are far more relevant as a way to find who is who in the programming contest world. Facebook's little cup is very young as an attempt to gain cred.