Skip to content

Instantly share code, notes, and snippets.

@KilJaeeun
Last active May 3, 2021 00:51
Show Gist options
  • Save KilJaeeun/7db68d57a366ffc6d4a0b349393d5d88 to your computer and use it in GitHub Desktop.
Save KilJaeeun/7db68d57a366ffc6d4a0b349393d5d88 to your computer and use it in GitHub Desktop.
๐ŸŒž Morning 138 commits โ–ˆโ–ˆโ–ˆโ–Œโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 16.8%
๐ŸŒ† Daytime 316 commits โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 38.4%
๐ŸŒƒ Evening 276 commits โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 33.6%
๐ŸŒ™ Night 92 commits โ–ˆโ–ˆโ–Žโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 11.2%
import collections
import copy
import heapq
import math
import sys
import time
def make_table(p):
length = len(p)
table = [0] * len(p)
j = 0
for i in range(1, length):
while j > 0 and p[i] != p[j]:
j = table[j - 1]
if p[i] == p[j]:
j += 1
table[i] = j
return table
def kmp(p, s):
table = make_table(p)
j = 0
answers = []
answer = 0
aaa = 0
for i in range(len(s)):
while j > 0 and s[i] != p[j]:
j = table[j - 1]
if s[i] == p[j]:
if j == len(p) - 1:
answers.append(i - j + 1)
answer += 1
j = table[j]
else:
j += 1
return answer, answers
def printTime():
start_time = int(round(time.time() * 1000))
main()
end_time = int(round(time.time() * 1000))
print('some_func()์˜ ์‹คํ–‰ ์‹œ๊ฐ„ : %d(ms)' % (end_time - start_time))
return
"""
bin(42)
int('0b111100', 2)
oct(42)
hex(42)
ord()
chr()
arr.reverse() # ๋ฐฐ์—ด ๊ฑฐ๊พธ๋กœ
list.count(์ฐพ๋Š” ๊ฐ’) # ๊ฐ’์ด ๋ฐฐ์—ด์— ๋ช‡ ๊ฐœ๊ฐ€ ์žˆ๋Š”์ง€( ๋ฌธ์ž์—ด๋„ ๊ฐ€๋Šฅ)
arr.sort(key=lambda x:(x[0], x[1]))
res = a if a > b else b
"""
sys.setrecursionlimit(10 ** 4)
input = sys.stdin.readline
def print(a):
sys.stdout.write(str(a))
def hpop(ALIST):
heapq.heapppop(ALIST)
def log2(i):
return math.log(i, 2)
def iinput(): return int(input())
def lisinput(): return list(map(int, input().split()))
def minput(): return map(int, input().split())
def liinput(): return list(map(int, list(input())))
def dq(): return collections.deque([])
def popl(a): return a.popleft()
def appendl(a, b):
a.appendleft(b)
return a
move = [
[-1, 0], # ์™ผ
[0, -1], # ์•„๋ž˜
[1, 0], # ์˜ค๋ฅธ์ชฝ
[0, 1], # ์œ„
]
def in_r(x, N):
return (0 <= x[0] and x[0] < N and 0 <= x[1] and x[1] < N)
def in_rc(x, r, c):
return (0 <= x[0] and x[0] < r and 0 <= x[1] and x[1] < c)
def addNode(a, b):
return [a[0] + b[0], a[1] + b[1]]
def returnValue(graph, node):
return graph[node[0]][node[1]]
def add(A, value, maps):
maps[A[0]][A[1]] += value
return maps
def transpose(graph):
return list(map(list, zip(*graph)))
def make_table():
length = len(p)
table = [0] * len(p)
j = 0
for i in range(1, length):
while j > 0 and p[i] != p[j]:
j = table[j - 1]
if p[i] == p[j]:
j += 1
table[i] = j
return table
def kmp():
table = make_table()
j = 0
for i in range(len(s)):
while j > 0 and s[i] != p[j]:
j = table[j - 1]
if s[i] == p[j]:
if j == len(p) - 1:
return True
else:
j += 1
return False
def dpcopy(m):
return copy.deepcopy(m)
def sec_to_time(sec):
h = sec // 3600
m = (sec % 3600) // 60
s = sec % 60
ans = []
if h < 10:
ans.append(0)
ans.append(h)
ans.append(':')
if m < 10:
ans.append(0)
ans.append(m)
ans.append(':')
if s < 10:
ans.append(0)
ans.append(s)
string = ''.join(list(map(str, ans)))
return string
def time_to_sec(play_time):
h, m, s = map(int, play_time.split(":"))
sec = 3600 * h + 60 * m + s
return sec
def split2times(log):
s, e = log.split("-")
return (time_to_sec(s), time_to_sec(e))
# ํ•ญ์ƒ ์‹œ๊ฐ„์€ min(๋๋‚œ ์‹œ๊ฐ„๋“ค) - max(์‹œ์ž‘ ์‹œ๊ฐ„๋“ค )
if __name__ == '__main__':
pass
import sys
input = sys.stdin.readline
def get_parent(x):
if parent[x] == x:
return x
p = get_parent(parent[x])
parent[x] = p
return p
def union(x, y):
x = get_parent(x)
y = get_parent(y)
if x != y:
parent[y] = x
def find_parent(x):
if parent[x] == x:
return x
return find_parent(parent[x])
n, m = map(int, input().split())
parent = {}
for i in range(n+1):
parent[i] = i
for _ in range(m):
z, x, y = map(int, input().split())
if not z:
union(x, y)
if z:
if find_parent(x) == find_parent(y):
print('YES')
else:
print('NO')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment