Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
78 changes: 78 additions & 0 deletions 이티준희/10026_적록색약.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#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()
Comment thread
Suanna01 marked this conversation as resolved.
Outdated

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)
Comment thread
Suanna01 marked this conversation as resolved.
Outdated
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'
Comment thread
Suanna01 marked this conversation as resolved.
Outdated

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)






50 changes: 50 additions & 0 deletions 이티준희/15723_n단 논법.py
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()
Comment thread
Suanna01 marked this conversation as resolved.
Outdated

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(N) :
for j in range(N) :
for k in range(N) :
Comment thread
Suanna01 marked this conversation as resolved.
Outdated
if graph[j][k] < graph[j][i] + graph[i][k] :
Comment thread
Suanna01 marked this conversation as resolved.
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')