1384 메시지 - Python
2024. 8. 6. 22:50ㆍ공부/📝 백준
1. 풀이 코드
num = 0
while True:
is_bullying = False
n = int(input())
num += 1
if n == 0:
break
people_list = []
for i in range(n):
paper = list(input().split(' '))
people_list.append(paper)
print(f"Group {num}")
for i in range(n):
target = people_list[i]
for j in range(n):
if target[j] == "N":
is_bullying = True
print(f"{people_list[(n + i - j)%n][0]} was nasty about {target[0]}")
if not is_bullying:
print("Nobody was nasty")
print()
2. 다른 사람 풀이 코드
c=1
while n:=int(input()):
print('Group',c)
r,f=[input().split()for _ in range(n)],1
for i in range(n):
for j in range(1,n):
if r[i][j]=='N':f=0;print(r[i-j][0],'was nasty about',r[i][0])
if f:print('Nobody was nasty')
c+=1
print()
'공부 > 📝 백준' 카테고리의 다른 글
30970 선택의 기로 - Python (0) | 2024.08.06 |
---|---|
26150 Identify, Sort, Index, Solve - Python (0) | 2024.08.06 |
23882 알고리즘 수업 - 선택 정렬 2 - Python (0) | 2024.08.06 |
1120 문자열 - Python (0) | 2024.08.04 |
11365 !밀비 급일 - Swift (0) | 2024.07.30 |