[Silver II] Title: 가로 세로 퍼즐, Time: 36 ms, Memory: 32412 KB -BaekjoonHub
This commit is contained in:
48
백준/Silver/2784. 가로 세로 퍼즐/README.md
Normal file
48
백준/Silver/2784. 가로 세로 퍼즐/README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# [Silver II] 가로 세로 퍼즐 - 2784
|
||||
|
||||
[문제 링크](https://www.acmicpc.net/problem/2784)
|
||||
|
||||
### 성능 요약
|
||||
|
||||
메모리: 32412 KB, 시간: 36 ms
|
||||
|
||||
### 분류
|
||||
|
||||
브루트포스 알고리즘, 구현
|
||||
|
||||
### 제출 일자
|
||||
|
||||
2025년 4월 22일 01:08:52
|
||||
|
||||
### 문제 설명
|
||||
|
||||
<p>아래와 같은 가로 세로 퍼즐을 풀어보자.</p>
|
||||
|
||||
<p style="text-align: center;"><img alt="" src="https://upload.acmicpc.net/45bdf75b-0280-4ae5-94b3-f91e742dc1e2/-/preview/" style="width: 149px; height: 125px;"></p>
|
||||
|
||||
<p>가로줄</p>
|
||||
|
||||
<ol>
|
||||
<li>device used to cool a PC</li>
|
||||
<li>solid water</li>
|
||||
<li>to obtain</li>
|
||||
</ol>
|
||||
|
||||
<p>세로줄</p>
|
||||
|
||||
<ol>
|
||||
<li>small, soft, sweet fruit</li>
|
||||
<li>strong playing card</li>
|
||||
<li>fisherman's tool</li>
|
||||
</ol>
|
||||
|
||||
<p>6개의 단어가 주어졌을 때, 이를 가지고 가로 세로 퍼즐을 만드는 프로그램을 작성하시오. 단어 3개는 가로줄, 3개는 세로줄로 배치해야한다.</p>
|
||||
|
||||
### 입력
|
||||
|
||||
<p>6개의 줄에 알파벳 대문자로 이루어진 단어가 주어진다. 이 단어는 사전순으로 정렬되어 있다.</p>
|
||||
|
||||
### 출력
|
||||
|
||||
<p>6개 단어를 3*3 가로 세로 퍼즐에 놓을 수 없다면 0을 출력한다. 그렇지 않다면, 3개 줄에 퍼즐을 출력한다. 만약 가능한 답이 여러개라면 사전순으로 앞서는 것을 출력한다. 사전순으로 비교를 할 때는, 모두 한 줄로 이어붙인 9개의 단어를 생각하면 된다.</p>
|
||||
|
||||
21
백준/Silver/2784. 가로 세로 퍼즐/가로 세로 퍼즐.py
Normal file
21
백준/Silver/2784. 가로 세로 퍼즐/가로 세로 퍼즐.py
Normal file
@@ -0,0 +1,21 @@
|
||||
arr = [input() for _ in range(6)]
|
||||
arr.sort()
|
||||
ans_list = []
|
||||
for i in range(6):
|
||||
for j in range(6):
|
||||
for k in range(6):
|
||||
if i == j or i == k or j == k:
|
||||
continue
|
||||
temp = [arr[i], arr[j], arr[k]]
|
||||
temp2 = temp.copy()
|
||||
for h in range(3):
|
||||
temp2.append(temp[0][h] + temp[1][h] + temp[2][h])
|
||||
temp2.sort()
|
||||
if arr == temp2:
|
||||
ans_list.append(temp[0] + temp[1] + temp[2])
|
||||
ans_list.sort()
|
||||
if len(ans_list):
|
||||
for i in range(0, 10, 3):
|
||||
print(ans_list[0][i:i + 3])
|
||||
else:
|
||||
print(0)
|
||||
Reference in New Issue
Block a user