Skip to content

Commit 05c867c

Browse files
committed
Add files via upload
1 parent c496f8a commit 05c867c

File tree

5 files changed

+108
-3
lines changed

5 files changed

+108
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
N, M = map(int, input().split())
2+
3+
S = {}
4+
for _ in range(N):
5+
S[input()] = 1
6+
7+
check = [input() for _ in range(M)]
8+
9+
10+
ans=0
11+
for chk in check:
12+
if chk in S:
13+
ans+=1
14+
15+
print(ans)

week15/bsw/1806_부분합.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
N, S = map(int, input().split())
2+
lst = list(map(int,input().split()))
3+
4+
l, r = 0, 0
5+
6+
answers = []
7+
sum_nums = 0
8+
while l<=r and r<N:
9+
print(lst[l], lst[r], sum_nums)
10+
11+
if sum_nums < S:
12+
sum_nums+=lst[r]
13+
r+=1
14+
15+
elif sum_nums >= S:
16+
answers.append(r-l)
17+
sum_nums-=lst[l]
18+
l+=1
19+
20+
21+
if not answers:
22+
print(0)
23+
else: print(sorted(answers)[0])
24+
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
T = int(input())
2+
3+
for _ in range(T):
4+
5+
N = int(input())
6+
7+
tree = {}
8+
for _ in range(N-1):
9+
parent, child = map(int, input().split())
10+
tree[child] = parent
11+
12+
all_nodes = set([i for i in range(1,N+1)])
13+
children = set(i for i in tree.keys())
14+
root = (all_nodes-children).pop()
15+
16+
tree[root] = -1
17+
18+
node1, node2 = map(int, input().split())
19+
20+
answers=[]
21+
for cur in [node1, node2]:
22+
visited=[]
23+
24+
while cur in tree.keys():
25+
visited.append(cur)
26+
cur = tree[cur]
27+
28+
answers.append(visited)
29+
# print(tree)
30+
# print(answers)
31+
visited1, visited2 = answers[0], answers[1]
32+
33+
short = len(set(visited1) & set(visited2))
34+
35+
print(visited1[-short])
36+
'''
37+
2
38+
3
39+
1 4
40+
5
41+
'''

week15/bsw/4358_생태학.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import sys
2+
input = sys.stdin.readline
3+
4+
d= {}
5+
total=0
6+
while 1:
7+
tree=input().strip('\n')
8+
if not tree:
9+
break
10+
11+
if tree not in d:
12+
d[tree] = 0
13+
d[tree] += 1
14+
total += 1
15+
16+
# print(total)
17+
18+
# 이거왜안됨????????
19+
# 반례 : 50.00
20+
# 쓰레기 같은 문제
21+
# for key in sorted(d):
22+
# print(key, round((d[key]*100)/total, 4))
23+
24+
dic=sorted(d.items())
25+
for k, v in dic:
26+
print(k, '%.4f' %round((v/total)*100, 4))
27+
28+
print(round(4.33, 4))

week4/bsw/12906_새로운 하노이 탑.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#12906 새로운 하노이 탑
2-
<<<<<<< HEAD
3-
=======
42

53
# 원판이 이동할 때마다 하노이 탑의 현재 상태를 저장해 재사용 해야 한다
64
# DP로 접근 -> 실패 -> BFS로 접근해야 한다
@@ -75,4 +73,3 @@
7573
q.append((A, B + C[-1], C[0:-1], count+1))
7674

7775

78-
>>>>>>> 8cf325e0cb82fd7c35edeb0f6e5599b40cf21d54

0 commit comments

Comments
 (0)