Once there was a pig, which was very fond of treasure hunting.One day, when it woke up, it found itself in a strange land of treasure. As for how to come in, or how to go out, no waysto know. Sad. The good news is, it was lucky that it got the treasure map. But there is a bad news too, this map is an encrypted map. You can think of it as a matrix of R*C. Each gridis a number of Hexadecimal, that is the number is between {‘0’,’1’,…’9’,’A’,’B’,…
Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it found itself in a strange land of treasure. As for how to come in, or how to go out, no ways to know. Sad. The good news is, it was lucky that it got the treasure map. But there is a bad news too, this map is an encrypted map. You can think of it as a matrix of R*C. Each grid is a number of Hexadecimal(十六进制), that is the number is between {‘0’,’1’,…’9’,’A’,’B’,…,’F’}, and the 4 length Binary number(4位二进制数) corresponding is the real treasure map. For example, the number '0' on the encrypted graph represents the actual map ‘0000’, and '1' represents the actual map ‘0001’, ... The 'A' represents the actual map ‘1010’, and 'F' represents the actual map ‘1111’. The owner of the treasure is very clever, he build some insuperable wall in the treasure to avoid stealing, we use ‘0’ to describe it. Obviously ‘1’ indicated that this grid bury exactly one diamond. The pig can only walk up to four adjacent squares in the upper, lower, left and right directions at a time. Wherever it goes, it will dig out the diamond in this grid(if there is diamond buried in the grid) and put the diamond in its own package. Though it has got the map, but doesn't know where it is in the peach blossom trap now, that means it could be at any ‘.’ in the matrix. It finds you smart to tell it how many diamonds it will get at most.