wrong's blog

By wrong, 15 years ago, In English

I participated in TopCoder High School Round3(TCHS2010 Round3). This blog is in codeforces, but I have English blog only here. So I will write some reports of other competitions.


Easy(250)

Problem Summary

There is a rectangular grid which has size widthxheight. Starting in the top left cell, tracing the border of the grid in clockwise order, writing a string (phrase + "."). Then you are to calculate subsection of this grid which has its top left corner at (x1, y1), and its bottom right corner at (x2, y2).

Solution

It's easy to calculate what is the letter in position (x, y). So you can simply iterate x from x1 to x2, and y from y1 to y2.


Medium(550)

Problem Summary

There is a paper which a maze is written on both side. There is one start and one goal. You can fold and unfold the paper on vertical line. You are to calculate the minimum required steps to solve the maze. 

Solution

The solution is BFS. But implementation is too hard.


Hard(950)

Problem Summary

You have twoBricks bricks which have 2 units wide and 1 unit high, and threeBricks bricks which have 3 units wide and 1 unit high. Then you are to build perfect rectangle with your bricks. How many kinds can you make rectangles?

Solution

First, consider how many rectangle which has width W and height 1 can be made. If you know this value, the answer is sum of these values iterating W from 1 to 500000. And you can calculate this value with binary search.

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

15 years ago, # |
  Vote: I like it +13 Vote: I do not like it
Binary search wasn't necessary - There are about 500000 * log(500000) rectangles whose area is <= 500000.