-
Notifications
You must be signed in to change notification settings - Fork 3
#26 : Week6_준희이티 #28
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
Open
devCharlotte
wants to merge
10
commits into
main
Choose a base branch
from
joonhee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
#26 : Week6_준희이티 #28
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
d5e1450
#26 : 10026_적록색약
devCharlotte 0d497b3
#26 : 15723_n단 논법
devCharlotte d578f03
#31 : 1931_회의실 배정
devCharlotte 2235669
#31 : 1654_랜선 자르기
devCharlotte 96bb239
#31 : 1931_회의실 배정
devCharlotte 983ad92
#34 : 2839_설탕 배달
devCharlotte 5942672
#34 : 15651_N과 M(3)
devCharlotte f63d963
#26 : 10026_적록색약
devCharlotte c96c366
#26 : 15723_n단 논법
devCharlotte ce5bc4a
#31 : 1931_회의실 배정
devCharlotte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #2023-05-18-Week6-과제 | ||
| #10026_적록색약 | ||
|
|
||
| ''' | ||
| 입력 : | ||
| 1. 입력 크기 1 ≤ N ≤ 100 | ||
| 2. 그리드 입력 (N*N) | ||
|
|
||
| 출력 : | ||
| 적록색약 아닌 사람의 구역, 적록색약인 사람의 구역 | ||
| ''' | ||
|
|
||
|
|
||
|
|
||
|
|
||
| #런타임 에러 발생 | ||
|
|
||
| from collections import deque | ||
| import sys | ||
| import string | ||
|
|
||
| sys.setrecursionlimit(100000) #재귀 | ||
| # input=sys.stdin.readline() -> 한 줄 단위 입력 | ||
| input=sys.stdin.readline | ||
|
|
||
| N = int(input()) | ||
| matrix = [list(input().rstrip()) for i in range(N)] | ||
|
|
||
| visited = [[0]*N for i in range(N)] #방문 안 한 상태로 설정 | ||
|
|
||
|
|
||
| def dfs(x,y) : | ||
|
|
||
| move_x = [-1,1,0,0] | ||
| move_y = [0,0,-1,1] | ||
|
|
||
| color = matrix[x][y] #R, G, B | ||
| visited[x][y] = True #방문 | ||
|
|
||
| for i in range(4) : #상하좌우 | ||
| new_x = x + move_x[i] | ||
| new_y = y + move_y[i] | ||
| if (0 <= new_x <= N - 1) and (0 <= new_y <= N - 1) and (visited[new_x][new_y] == False): | ||
| if color == matrix[new_x][new_y] : | ||
| dfs(new_x,new_y) | ||
|
|
||
| #정상 | ||
| normal = 0 | ||
|
|
||
| for x in range(N) : | ||
| for y in range(N) : | ||
| if visited[x][y] == False : | ||
| dfs(x,y) | ||
| normal += 1 | ||
|
|
||
| #적록색약 | ||
| noRG = 0 | ||
| for x in range(N) : #적록색약 기준으로 색 변경 | ||
| for y in range(N) : | ||
| if matrix[x][y] == 'R' or matrix[x][y] == 'G' : | ||
| matrix[x][y] = 'g' | ||
|
|
||
| visited = [[0]*N for i in range(N)] #방문횟수 초기화 | ||
| for x in range(N) : | ||
| for y in range(N) : | ||
| if visited[x][y] == False : | ||
| dfs(x,y) | ||
| noRG += 1 | ||
|
|
||
| #출력 | ||
| print(normal, noRG) | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #15651_N과 M(3) | ||
| # -> 런타임에러 발생 | ||
| N, M = map((int, input()).split()) | ||
|
|
||
| list = [] | ||
|
|
||
| def func() : | ||
| if len(list) < M : | ||
| for i in range(1, N+1) : | ||
| list.append(i) | ||
| func() | ||
| list.pop() | ||
|
|
||
| else : | ||
| print(*list) | ||
|
|
||
| func() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| #2023-05-18-Week6-과제 | ||
| #15723_n단 논법 | ||
|
|
||
| ''' | ||
| n개의 전제가 있을 때 m개의 결론을 도출 | ||
|
|
||
| 입력 : | ||
| 정수 n(2 ≤ n ≤ 26) | ||
| 둘째 줄부터 n개의 줄에 걸쳐 각 줄에 전제가 하나씩 | ||
| a is b의 형식 | ||
| a는 b이면서 c일 수 없으나, a와 b가 동시에 c일 수는 있다. | ||
|
|
||
| 출력 : | ||
| m개의 줄에 걸쳐 각 줄에 결론이 참인지 거짓인지 | ||
| ''' | ||
|
|
||
|
|
||
| #런타임 에러 발생 | ||
|
|
||
| import sys | ||
| input = sys.stdin.readline | ||
|
|
||
| N = int(input()) | ||
| graph = [[0] * 26 for i in range(26)] | ||
|
|
||
|
|
||
| #입력한 알파벳 순서를 어떻게 정해야할까............. | ||
| order = "abcdefghijklmnopqrstuvwxyz" #알파벳 문자열의 인덱스로..? | ||
|
|
||
|
|
||
| for i in range(N) : | ||
| a, b = map(order.index, input().strip().split(" is ")) | ||
| graph[a][b] = 1 | ||
|
|
||
| for i in range(26) : | ||
| for j in range(26) : | ||
| for k in range(26) : | ||
| if graph[j][k] < graph[j][i] + graph[i][k] : | ||
| graph[j][k] = graph[j][k] | ||
| else : | ||
| graph[j][k] = graph[j][i] + graph[i][k] | ||
|
|
||
| M = int(input()) | ||
|
|
||
| for i in range(M) : | ||
| a, b = map(order.index, input().strip().split(" is ")) | ||
| if graph[a][b] != 0 : | ||
| print('T') | ||
| else : | ||
| print('F') | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #2023-05-25-Week7-과제 | ||
| #1654_랜선 자르기 | ||
|
|
||
| ''' | ||
| 가지고 있는 K개의 랜선을 잘라서 | ||
| N개의 같은 길이 랜선으로 만들기 | ||
| -> K=300일 때 N의 길이가 140이면 N=2, 20은 버려짐 | ||
|
|
||
| 기존 K개의 랜선으로 N개를 만들 수는 없음 | ||
| 자를 때는 정수 단위로만 자름 | ||
|
|
||
| N개보다 많이 만드는 것도 N개를 만드는 것에 포함 | ||
|
|
||
|
|
||
| 입력 1 : 이미 가지고 있는 K개, 필요한 랜선 N개 | ||
| (1<=K<=10000 1<=N<=1000000 K<=N) | ||
| 입력 2 : 이미 가지고 있는 K개의 랜선 각 길이 | ||
|
|
||
| 랜선의 길이는 자연수<=2^31 -1 | ||
|
|
||
| 출력 : N개를 만들 수 있는 랜선의 최대 길이 | ||
| ''' | ||
|
|
||
|
|
||
| import sys | ||
| K, N = map(int, sys.stdin.readline().split()) | ||
|
|
||
| array = [] | ||
|
|
||
| for i in range(K): | ||
| array.append(int(sys.stdin.readline())) | ||
|
|
||
| start = 1 # 최소 1 | ||
| end = max(array) # 최대 | ||
|
|
||
| while (start <= end): # 이분탐색 | ||
| # --> start와 end가 동일하면 탈출 = 최대 랜선 길이 발견 | ||
| mid = (start + end) // 2 # 중간 지점 값 | ||
| cnt = 0 # 랜선 개수 0 | ||
| for i in range(K) : | ||
| cnt += array[i] // mid # 랜선을 중간 값으로 나누어 개수 파악 | ||
| if cnt >= N : # 랜선 개수가 목표 이상 = 중간 기준으로 오른쪽 탐색 | ||
| start = mid + 1 | ||
| else : # 랜선 개수가 목표 미만 = 중간 기준으로 왼쪽 탐색 | ||
| end = mid - 1 | ||
|
|
||
| print(end) | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| #2023-05-25-Week7-과제 | ||
| #1931_회의실 배정 | ||
|
|
||
| ''' | ||
| 한 개의 회의실을 사용하려는 N개의 회의에 대한 사용표 | ||
| 시작시간, 종료시간 고정 | ||
| 시간이 겹치지 않게 회의실 사용하는 최대 회의 개수 | ||
|
|
||
| * 중간 중단 x | ||
| * 종료 동시에 다음 회의 시작 o | ||
| * 회의 시작하자마자 종료 o | ||
| * 시작시간 종료시간 0<=자연수<=2^31 -1 | ||
|
|
||
| 입력 1 : 회의 개수 1<=N<=100000 | ||
| 입력 2 : 회의 정보 -> 시작 공백 종료 | ||
|
|
||
| 출력 : 회의 최대 개수 | ||
| ''' | ||
|
|
||
| ''' | ||
| 1. 시작시간이 빠른 순서 -> 시작시간이 같은 경우 = 종료시간이 빠른 순서 | ||
| (2,3) (2,7) :: (2,3) -> (2,7) | ||
| 2. 종료시간이 빠른 순서 -> 종료시간이 같은 경우 = 시작시간이 빠른 순서 | ||
| (7,7) (2,7) :: (2,7) -> (7,7) | ||
|
|
||
| (2,7) (3,5) (6,7) 입력시 | ||
| by 1번 :: (2,7) 회의 1개 | ||
| by 2번 :: (3,5) (6,7) 회의 2개 | ||
|
|
||
| --> 종료 시간이 빠른 순서, | ||
| 같은 경우에는 시작 시간이 빠른 순서 | ||
| ''' | ||
|
|
||
|
|
||
| ### 런타임 에러(23-05-30) -> 시간 정렬 순서 변경함 (23-06-01) | ||
|
|
||
| import sys | ||
| N = int(sys.stdin.readline()) | ||
|
|
||
| time = [] | ||
| # 시간 저장하는 리스트 | ||
| # -> 처음부터 공간을 할당 받고 시작? 입력 받은 만큼 append? | ||
|
|
||
| cnt = 0 # 출력할 회의 개수 | ||
|
|
||
| for _ in range(N): | ||
| start, end = map(int, sys.stdin.readline().split()) | ||
| time.append([start, end]) | ||
|
|
||
| time = sorted(time, key = lambda time: time[0]) # 시작 시간 sort | ||
| time = sorted(time, key = lambda time: time[1]) # 종료 시간 sort | ||
|
|
||
| final = 0 # 마지막 회의 시간 | ||
|
|
||
| for i, j in time: | ||
| if i >= final: # 시작 >= 마지막 회의 | ||
| cnt += 1 | ||
| final = j # 갱신 | ||
|
|
||
| print(cnt) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # 2839_설탕 배달 | ||
| # -> 정답 | ||
|
|
||
| N = int(input()) | ||
| count = 0 | ||
|
|
||
| while N >= 0: | ||
| if N % 5 == 0 : # 전체 무게의 합을 5로 나누었을 때 나누어 떨어지면 | ||
| count += N // 5 # 그 몫 만큼 봉지 추가 | ||
| print (count) # 총 봉지 수 출력 | ||
| break | ||
| N -= 3 # 전체 무게의 합에서 3 빼기 | ||
| count += 1 # 3kg 봉지 한 개 추가 | ||
|
|
||
| if N < 0 : # 봉지를 만들 수 없는 음수 | ||
| print(-1) # -1 출력 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.