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
9 changes: 9 additions & 0 deletions 0321minji/[week09]/10610.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
n=list(input())
n.sort(reverse=True)

n=int("".join(n))
if n%30==0:
print(n)
else:
print(-1)

28 changes: 28 additions & 0 deletions 0321minji/[week09]/1213.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

input=sys.stdin.readline

name=input().rstrip()
check={}
for i in list(name):
if i not in check:
check[i]=1
else:
check[i]+=1

cnt=0
mid=''
for a,c in list(check.items()):
if c%2==1:
cnt+=1
mid=a
if cnt>1:
print("I'm Sorry Hansoo")
exit()
result=''
for a,c in sorted(check.items()):
result+=(a*(c//2)) #앞부분만 만드는 것-> 사용되는 알파벳 수/2

result=result+mid+result[::-1]

print(result)
28 changes: 28 additions & 0 deletions 0321minji/[week09]/1647.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import sys

input=sys.stdin.readline

name=input().rstrip()
check={}
for i in list(name):
if i not in check:
check[i]=1
else:
check[i]+=1

cnt=0
mid=''
for a,c in list(check.items()):
if c%2==1:
cnt+=1
mid=a
if cnt>1:
print("I'm Sorry Hansoo")
exit()
result=''
for a,c in sorted(check.items()):
result+=(a*(c//2)) #앞부분만 만드는 것-> 사용되는 알파벳 수/2

result=result+mid+result[::-1]

print(result)
47 changes: 47 additions & 0 deletions 0321minji/[week09]/21924.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#kruskal

import sys
input=sys.stdin.readline

def find(x):
if x!=parent[x]:
parent[x]=find(parent[x])
return parent[x]

def union(x,y):
a=find(x)
b=find(y)

if a<b:
parent[b]=a
else:
parent[a]=b


def kruskal(v,total,pq):
cnt=0

for w,a,b in pq:
if find(a)!=find(b):
union(a,b)
total-=w
for i in range(1,n):
if i==parent[i]:
cnt+=1

if cnt>1:
return -1
else:
return total

n,m=map(int,input().split())
parent=[ i for i in range(n+1)]
pq=[]
total=0

for _ in range(m):
a,b,c=map(int,input().split())
pq.append((c,a,b))
total+=c
pq.sort()
print(kruskal(n,total,pq))