Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[제리] 3주차, 4주차, 5주차 #46

Open
wants to merge 5 commits into
base: Hyeonjae-K
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
__pycache__/
18 changes: 18 additions & 0 deletions 1주차/1051.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
n, m = map(int, input().split())
rows = [input() for _ in range(n)]


def is_square(i, j, k):
return rows[i][j] == rows[i][j+k] and \
rows[i][j] == rows[i+k][j] and \
rows[i][j] == rows[i+k][j+k]


result = 1
for i in range(n-1):
for j in range(m-1):
k = min(n-i-1, m-j-1)
for l in range(1, k+1):
if is_square(i, j, l):
result = max(result, (l+1)**2)
print(result)
18 changes: 18 additions & 0 deletions 1주차/3273.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
n = int(input())
nums = sorted(list(map(int, input().split())))
x = int(input())

head = 0
tail = n-1
result = 0
while head < tail:
sum = nums[head] + nums[tail]
if sum == x:
head += 1
tail -= 1
result += 1
elif sum < x:
head += 1
else:
tail -= 1
print(result)
10 changes: 10 additions & 0 deletions 2주차/10989.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import sys

result = [0] * 10_001

for _ in range(int(sys.stdin.readline())):
result[int(sys.stdin.readline())] += 1

for i, n in enumerate(result):
for _ in range(n):
print(i)
33 changes: 33 additions & 0 deletions 2주차/13901.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
R, C = map(int, input().split())
board = [[True] * C for _ in range(R)]
for _ in range(int(input())):
br, bc = map(int, input().split())
board[br][bc] = False
r, c = map(int, input().split())
directions = [x-1 for x in map(int, input().split())]
dx = [0, 0, -1, 1]
dy = [-1, 1, 0, 0]

board[r][c] = False


def is_movable(r: int, c: int) -> bool:
return -1 < r and r < R and -1 < c and c < C and board[r][c]


moved = True
direction = 0
while moved:
moved = False
board[r][c] = False

for _ in range(4):
x = c + dx[directions[direction]]
y = r + dy[directions[direction]]
if is_movable(y, x):
moved = True
r, c = y, x
break
direction = (direction + 1) % 4

print(r, c)
6 changes: 6 additions & 0 deletions 2주차/2751.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

nums = sorted([int(sys.stdin.readline())
for _ in range(int(sys.stdin.readline()))])

print('\n'.join(list(map(str, nums))))
16 changes: 16 additions & 0 deletions 3주차/10773.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys

top = -1
stack = [0] * 100_000
for _ in range(int(sys.stdin.readline())):
n = int(sys.stdin.readline())
if n == 0 and top != -1:
top -= 1
else:
top += 1
stack[top] = n

if top == -1:
print(0)
else:
print(sum(stack[:top+1]))
17 changes: 17 additions & 0 deletions 3주차/2799.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
N, M = map(int, input().split())
windows = [input() for _ in range(N*5+1)]


def get_status(r: int, c: int) -> int:
for i in range(5):
if windows[r+i][c] != '*':
return i


result = [0] * 5
for r in range(N):
for c in range(M):
status = get_status(r*5+1, c*5+1)
result[status] += 1

print(' '.join(map(str, result)))
8 changes: 8 additions & 0 deletions 4주차/15649.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from itertools import permutations

N, M = map(int, input().split())

answers = list(permutations([str(i) for i in range(1, N+1)], M))

for answer in answers:
print(' '.join(answer))
30 changes: 30 additions & 0 deletions 4주차/2503.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from itertools import permutations

nums = list(permutations([i for i in range(1, 10)], 3))


def get_count(n: int, num: tuple):
s = b = 0
for i, k in enumerate(str(n)):
k = int(k)
if k == num[i]:
s += 1
elif k in num:
b += 1
return s, b


for _ in range(int(input())):
n, s, b = map(int, input().split())
gap = 0

for i in range(len(nums)):
i -= gap

s_count, b_count = get_count(n, nums[i])

if s_count != s or b_count != b:
nums.remove(nums[i])
gap += 1

print(len(nums))
61 changes: 61 additions & 0 deletions 5주차/14500.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import sys


N, M = map(int, sys.stdin.readline().split())
board = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]

max_val = 0
visited = [[False] * M for _ in range(N)]
moves = [(0, 1), (0, -1), (1, 0), (-1, 0)]


def get_next(r, c, i):
return r + moves[i][0], c + moves[i][1]


def is_valid(r, c):
return 0 <= r and r < N and 0 <= c and c < M and not visited[r][c]


def dfs(i, j, val, cnt):
global max_val

if cnt == 4:
max_val = max(max_val, val)
return

for k in range(4):
r, c = get_next(i, j, k)

if is_valid(r, c):
visited[r][c] = True
dfs(r, c, val + board[r][c], cnt+1)
visited[r][c] = False


def fxxk(i, j):
global max_val

for k in range(4):
val = board[i][j]

for l in range(3):
move = (k+l) % 4
r, c = get_next(i, j, move)

if not is_valid(r, c):
val = -1
break
val += board[r][c]

max_val = max(max_val, val)


for i in range(N):
for j in range(M):
visited[i][j] = True
fxxk(i, j)
dfs(i, j, board[i][j], 1)
visited[i][j] = False

print(max_val)
32 changes: 32 additions & 0 deletions 5주차/18258.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys

head = 0
tail = -1
queue = [0] * 2_000_000

for _ in range(int(sys.stdin.readline())):
command = sys.stdin.readline().split()

if command[0] == 'push':
tail += 1
queue[tail] = command[1]
elif command[0] == 'pop':
if head > tail:
print(-1)
else:
print(queue[head])
head += 1
elif command[0] == 'size':
print(tail - head + 1)
elif command[0] == 'empty':
print(1 if head > tail else 0)
elif command[0] == 'front':
if head > tail:
print(-1)
else:
print(queue[head])
elif command[0] == 'back':
if head > tail:
print(-1)
else:
print(queue[tail])
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<br/>

## 규칙 1
- 매주 월요일 ~ 토요일 해결할 문제가 최소 2문제입니다.
- 매주 월요일 ~ 토요일 해결할 문제는 최소 2문제입니다.
- 공통적으로 주어지는 구현 문제 1문제를 해결합니다.
- 자신이 공부하고 싶은 알고리즘 유형을 1개 정하고, 관련된 문제 최소 1문제를 해결합니다.
- PR은 매주 토요일 자정까지 제출합니다.
- PR 제목: `[로건] 1주차 제출`
- 🙌 PR 브랜치는 레벨 1, 레벨 2처럼 자신의 닉네임 브랜치에 보냅니다.
- PR 제목: `[로건] - 1주차 제출`
- PR 내용: `제출하는 문제 번호 혹은 이름` + `설명하고 싶은 문제 풀이`
- PR 경로: `N주차 폴더` - `크루 이름 폴더` - `문제 소스 코드 파일`
- ex) `1주차/로건/BOJ_1234.py`
Expand All @@ -20,21 +21,20 @@
아래 내용중에 정해진 실전 연습을 일주일에 한 번 진행합니다.
- 백준 - 그룹 - 연습 기능을 사용합니다. ([백준 그룹 링크](https://www.acmicpc.net/group/18114))
- 프로그래머스에 있는 코테 기출을 연습합니다. (ex. 카카오 기출)
- 오프라인 / 온라인은 추후 이야기가 필요합니다.
- +) 기업 코딩테스트에 참여하면 해당 주차는 실전 연습에 참여하지 않아도 됩니다.

<br/>

## 문제 난이도
문제 난이도는 아래 기준에 해당해야 합니다.
- 백준 : [solved.ac](https://solved.ac) 기준 브론즈 ~ 골드 중하위
- 백준 : [solved.ac](https://solved.ac) 기준 브론즈 ~ 골드 3
- 프로그래머스 : Lv.1 ~ Lv.3

<br/>

## 벌칙
규칙 1 혹은 규칙 2를 어길 때마다 아래 벌칙을 수행해야 합니다.
- 커피 한잔씩 돌리기
- 벌금 5000원

<br/>

Expand All @@ -56,6 +56,6 @@

## 구성원

| <img src="https://avatars.githubusercontent.com/u/79046106?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/90550065?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/77962265?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/91244090?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/62413589?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/91937954?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/71651608?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/63213487?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/32128848?v=4" alt="" width=200> |
| :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
| [로건](https://github.com/70825) | [로이스](https://github.com/TaeyeonRoyce) | [모디](https://github.com/jaehee329) | [우가](https://github.com/wugawuga) | [우르](https://github.com/java-saeng) | [제나](https://github.com/yenawee) | [제리](https://github.com/Hyeonjae-K) | [제이](https://github.com/sosow0212) | [홍실](https://github.com/hong-sile) |
| <img src="https://avatars.githubusercontent.com/u/79046106?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/90550065?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/52229930?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/77962265?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/83010167?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/91522259?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/91244090?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/62413589?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/91937954?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/71651608?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/63213487?v=4" alt="" width=200> | <img src="https://avatars.githubusercontent.com/u/32128848?v=4" alt="" width=200> |
| :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------: |
| [로건](https://github.com/70825) | [로이스](https://github.com/TaeyeonRoyce) | [말랑](https://github.com/shin-mallang) |[모디](https://github.com/jaehee329) | [에단](https://github.com/wugawuga) | [오잉](https://github.com/hanueleee) | [우가](https://github.com/wugawuga) | [우르](https://github.com/java-saeng) | [제나](https://github.com/yenawee) | [제리](https://github.com/Hyeonjae-K) | [제이](https://github.com/sosow0212) | [홍실](https://github.com/hong-sile) |