시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 5 | 4 | 4 | 100.000% |
Cows like to build shapes out of hay bales. Each new shape is constructed from N (1 ≤ N ≤ 25,000) 1 x 1 x 1 cubic bales.
Bale 1 lies on the floor. After placing it, each successive bale from 2 through N is attached to the shape by placing the new bale in the proper relative position to one of the bales already placed. For instance, imagine the following figure:
This results in an (inverted) L-shape:
+--+--+ 1-> / / /| <-2 +--+--+ + | / /|/ ++--+ + / /|/ <-3 +--+ + | |/ <-4 +--+
Adding another bale:
adds height to the shape:
+--+ / /| +--+ +--+ 5-> | |/ /| <-2 +--+--+ + 1-> | / /|/ ++--+ + / /|/ <-3 +--+ + | |/ <-4 +--+
But adding another directive:
results in an invalid shape, since bales 3 and 6 would overlap.
Given N bales and placements described as above, output the exposed surface area of the solid figure if the shape is valid. A face is considered exposed if it is not touched by any face of any other bale and does not touch the floor (i.e., is not the bottom of a cube on the floor). Output -1 if the shape is invalid. No bale will be placed farther than 25 bale-widths from the first bale. No bale will be placed below the floor level.
5 1 R 2 F 3 F 1 O
18