When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

hmehta's blog

By hmehta, history, 4 years ago, In English

Topcoder MM 114 is scheduled to start at 21:00 UTC -5 on Jan 22, 2020. To find out what time this Marathon Match starts in your local time zone, click here

Register Now!

TCO20 Eligible: Competing in Marathons can help you qualify for TCO20 Marathon Tournament Finals. Learn More.

How to compete?
In order to compete in a Topcoder Marathon Match, you will need to click the Register button next to the appropriate Marathon Match within the Active Contests list and agree to the rules of the event.

Want to Practice?
To understand what kind of problems do Marathon Matches have and to get the feel of a Topcoder Marathon Match you can visit the practice rooms and participate in the Marathon Matches previously hosted on Topcoder. 

Best of luck!!

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

| Write comment?
»
4 years ago, # |
  Vote: I like it +10 Vote: I do not like it

The problem statement is now available. :)

Problem Statement

You work as a snake charmer and you want to impress the crowd with your skilful control of the snake. The snake comes out from the middle cell of a NxN grid. At each step, you can make its head move into any of the four adjacent (horizontally and vertically) cells. The snake cannot leave the grid or run into itself. The snake is divided into sections containing numbers, where each section is one grid cell in length. You get points based on the patterns that you make with the snake's sections. In particular, you get v^(m+1) points for each section, where v is the section's value and m is the number of adjacent (horizontally and vertically) cells with value v.

Here is an example solution for seed=1, N=7, V=3, Snake="3444433322344332432434424422324243233232232424424". This solution obtains a raw score of 3339. The black line shows the path that the snake travelled. The colour of a cell indicates the number of its matching neighbours. The head and the tail of the snake are shown inside a black square. Note that the entire snake does not need to come out.