1041번: 주사위
Difficulty: Gold V
Problem Description
There is a die drawing.
Input is N, A, B, C, D, E, F. And you have to make N*N*N cube by using many dice.
After that, the output is the sum of all numbers written on the five surfaces of the cube which can be shown.
(The bottom surface cannot be shown because of the ground.)
Solution
I solved this problem by dividing the surface into three parts.
Vertex, edge, and the inner side.
N is the length of edge, and num is the list of A~F.
If the N is 1, I can't use the formula below, so handle it separately.
For every dice, both sides never be shown to the surface at the same time.
So only the less one is needed. After that, sort the list because of the next calculation.
There are three parts divided by '+'.
The first one is the inner side. They will show only one face, so count them and multiply by the minimum number.
The second is vertex. There are only 4 vertices. So add all three numbers and multiple them by 4.
The last is edge. there are 4 vertical edge and 4 horizontal edge.
But it is important that the length of two edges are different.
The length of the vertical edge is N-1 because the bottom die is in contact with the ground.
Only two faces are visible, so it is included in the edge. And the horizontal edge are not.
So there are 4 * (N-1) + 4 * (N-2) dice included in the edge. In short, 8N-12.
Today's English
die-dice : 단수-복수
vertex-vertices : 꼭짓점 단수-복수
in contact with : ~와 닿아 있다
여담
처음으로 골드 문제를 도전해 보았는데 예상보다 많이 쉬웠다. 걸린 시간만 보면 브론즈와 비교될 정도니...
앞서 풀었던 두 문제가 체감 난이도는 훨씬 어려웠다.
물론 한번에 맞지는 못했지만 N=1일때 예외처리, 문법, 수식 등 간단한 문제점만 고쳤을 뿐
해결 방식 자체는 보자마자 생각해 냈다.
저번 글에서도 말했다시피 본인이 알고리즘마다 해결 능력의 편차가 매우 커서 발생한 문제인 듯 싶다.
실버 4정도에서 끙끙대면서 내가 이정도밖에 안되나 상심했는데 오늘 문제를 풀고 자신감을 좀 되찾은 것 같다.