goosegoose.DRAM
article thumbnail
뿅뿅망치 팀 2023 하계 모각코 활동6

https://www.acmicpc.net/problem/7785 7785번: 회사에 있는 사람 첫째 줄에 로그에 기록된 출입 기록의 수 n이 주어진다. (2 ≤ n ≤ 106) 다음 n개의 줄에는 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는 www.acmicpc.net import sys hash = {} num = int(sys.stdin.readline()) for _ in range(num): name, situation = map(str, sys.stdin.readline().split()) if situation == 'leave': del hash[name] else: hash[name] = situation r..

article thumbnail
뿅뿅망치 팀 2023 하계 모각코 활동 3

union find 문제를 풀어보자! https://www.acmicpc.net/problem/1717 1717번: 집합의 표현 초기에 $n+1$개의 집합 $\{0\}, \{1\}, \{2\}, \dots , \{n\}$이 있다. 여기에 합집합 연산과, 두 원소가 같은 집합에 포함되어 있는지를 확인하는 연산을 수행하려고 한다. 집합을 표현하는 프로그램을 작 www.acmicpc.net c 언어로 풀어봤다 # #include # #include int parent[1000000]; int Find(int x){ if (x == parent[x]){ return x; } else{ return parent[x] = Find(parent[x]); } } void Union(int x, int y){ x = F..