Skip to content
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
39 changes: 39 additions & 0 deletions jinny/20920.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 7 4
# apple
# ant
# sand
# apple
# append
# sand
# sand


# 1.자주
# 2.길수록
# 3.알파벳
# 4. m길이 이상

import sys


n,m = map(int, input().split())
word = {}
for i in range(n):
word_str = sys.stdin.readline().strip()

if len(word_str) >= m :
if word_str in word:
word[word_str] +=1
else :
word[word_str] =1
else :
continue;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from collections import Counter
로 카운터 사용하면 개수 쉽게 구할 수 있더라! 종종 유용하게 쓰이는데 참고 ~~


#print(word)
sorted_word = sorted(word.items(), key=lambda item: (-item[1], -len(item[0]), item[0]))
#print(sorted_word)

for key in sorted_word:
print(key[0])


38 changes: 38 additions & 0 deletions jinny/5014.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from collections import deque


F, S ,G ,U ,D = map(int, input().split())
visit = [False] * (F + 1)
count = [0] * (F + 1)

def bfs(node):
global visit,count
q = deque()
q.append(node)
visit[node] = True

while q:
x = q.popleft()

if x == G:
visit[x] = True
return count[G]

for i in (x+U, x-D):

if 0 < i <= F and not visit[i]:
#print("set")
#print(i)
visit[i] = True
count[i] = count[x] + 1
q.append(i)

if count[G] == 0:
return "use the stairs"

print(bfs(S))





54 changes: 54 additions & 0 deletions jinny/신고결과받기.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
def solution(id_list, report, k):
report = set(report)
dict = {}
for i in report:
nm=i.split()
if nm[0] in dict:
dict[nm[0]] +=[nm[1]]
else:
dict[nm[0]] = [nm[1]]

#print(dict)

value_dic = []
for i in dict.values():
value_dic +=i

#print(value_dic)

stop_value = []
for i in id_list:
if i in value_dic:
if value_dic.count(i) >= 2:
stop_value += [i]

#print(stop_value)

answer = []
for i in id_list:
if i in dict.keys():
#print("몰라"+i)
count = 0
for j in dict[i]:
if j in stop_value:
count+=1
answer.append(count)
else :
answer.append(0)
return answer
def main():
# 입력 예시
id_list_1 = ["muzi", "frodo", "apeach", "neo"]
report_1 = ["muzi frodo", "apeach frodo", "frodo neo", "muzi neo", "apeach muzi"]
k_1 = 2

id_list_2 = ["con", "ryan"]
report_2 = ["ryan con", "ryan con", "ryan con", "ryan con"]
k_2 = 3

# 결과 출력
print(solution(id_list_1, report_1, k_1)) # [2, 1, 1, 0]
print(solution(id_list_2, report_2, k_2)) # [0, 0]

if __name__ == "__main__":
main()