Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- aws ์ฟ ํฐ
- AWS Certified Solutions Architect - Associate
- ์๋ฒ ํฐ์ง๋ ๋์ปค ์ฌ์คํ
- docker ps -a
- Kafka
- Entity
- s3 ์ด๋ฏธ์ง ์ ์ฅ
- ์ ํจ์ค ๋น๋ ์ค๋ฅ
- ๋ค์ค ์ปจํ ์ด๋
- ์คํํ๋ ๋ฏธ์ค
- nGrinder
- redis ์กฐํ
- Codedeploy ์ค๋ฅ
- redis ํ ์คํธ์ฝ๋
- ์ ํจ์ค ์ค์ผ์ค๋ฌ
- ํ๋ก๊ทธ๋๋จธ์ค
- docker
- ํ์ดํผ๋ฐ์ด์
- jvm ๋ฐ๋ฐ๋ฅ๊น์ง ํํค์น๊ธฐ
- s3 ์ด๋ฏธ์ง ๋ค์ด๋ก๋
- ์๋ฐ
- ํ๋ก๊ทธ๋๋จธ์ค ์ปฌ๋ฌ๋ง๋ถ
- prod docker-compose
- docker compose
- private subnet ec2 ๋ก์ปฌ ์ ์
- s3 log ์ ์ฅ
- ํ๋ก๊ทธ๋๋จธ์ค ํฉ์นํ์์๊ธ
- docker-compose kafka
- JPA
- aws saa ํฉ๊ฒฉ
Archives
- Today
- Total
๐๐ข๐๐ โ๐๐๐ ๐๐๐ก๐๐ ๐๐๐๐โง
[Python] ๋ฐฑ์ค 1759 & ๋ฐฑ์ค 1987 ๋ณธ๋ฌธ
๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป/[๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ
[Python] ๋ฐฑ์ค 1759 & ๋ฐฑ์ค 1987
๐คRyusun๐ค 2023. 7. 26. 13:54# ๋ฐฑ์ค 1759
def solution(depth, index, word):
if depth == L:
vo, co = 0, 0
for w in word:
if w in 'aeiou':
vo += 1
else:
co += 1
if vo >= 1 and co >= 2:
print(word)
return
for i in range(index, C):
solution(depth+1, i+1, word + memo[i])
L, C = map(int, input().split())
memo = list(input().split())
memo.sort()
solution(0, 0, "")
#1987 ์ํ๋ฒณ
import sys
input = sys.stdin.readline
n, m = map(int, input().split(' ')) # ์ธ๋ก, ๊ฐ๋ก
graph = [list(map(str, input().rstrip())) for _ in range(n)]
queue = set()
d_row = [0, -1, 0, 1]
d_col = [1, 0, -1, 0]
def bfs():
word = graph[0][0]
queue.add((0, 0, word))
global result
while queue:
x, y, word = queue.pop()
result = max(result, len(word))
for i in range(4):
nx = x + d_row[i]
ny = y + d_col[i]
if nx <0 or ny < 0 or nx> n-1 or ny > m-1:
continue
if graph[nx][ny] in word:
continue
queue.add((nx, ny, word+graph[nx][ny]))
result = 0
bfs()
print(result)
queue = deque()๋ก ํ๋๋ ์๊ฐ์ด๊ณผใ ใ
set์ผ๋ก ํ๋๋ ์ฑ๊ณต
๐ queue vs set
- deque์ ์๊ฐ๋ณต์ก๋๋ O(1)
- set์ ์๊ฐ๋ณต์ก๋๋ O(1)
ํ์ง๋ง queue์ ์ค๋ณต์ ํ์ฉํ๊ธฐ ๋๋ฌธ์ ์ค๋ณต๋ ๊ฐ ๋ฃ์ด๋ ๊ณ์ฐํด์ ์๊ฐ์ด๊ณผ๋จ
๊ทธ๋์ set์ผ๋ก ์ค๋ณต ํ์ฉํ์ง์์ผ๋ฉด ์๊ฐ์ด ๋จ์ถ๋๋ค.
'๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ด๐ป > [๐๐ฒ๐ญ๐ก๐จ๐ง] ๐๐ฅ๐ ๐จ๐ซ๐ข๐ญ๐ก๐ฆ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Python] ๋ฐฑ์ค 1743 & 1303 (0) | 2023.08.27 |
---|---|
[Python] ๋ฐฑ์ค 5014 & ํ๋ก๊ทธ๋๋จธ์ค ์คํ์ฑํ ๋ฐฉ (0) | 2023.07.31 |
[Python] ๋ฐฑ์ค 1325 & ๋ฐฑ์ค 1668 (0) | 2023.07.25 |
[Python] ๋ฐฑ์ค 1012 & ๋ฐฑ์ค 2667 (0) | 2023.07.25 |
[Python] ๋ฐฑ์ค 1461 & ๋ฐฑ์ค 2212 (0) | 2023.06.25 |