[[TableOfContents]] = 오늘의 실습 내용 = * 필수 * [https://www.acmicpc.net/problem/11279 최대 힙] * [https://www.acmicpc.net/problem/1260 DFS와 BFS] * [https://www.acmicpc.net/problem/1922 네트워크 연결] * 선택 * [https://www.acmicpc.net/problem/2957 이진 탐색 트리] * [https://www.acmicpc.net/problem/1717 집합의 표현] * [https://www.acmicpc.net/problem/1199 오일러 회로] * [https://www.acmicpc.net/problem/11724 연결 요소의 갯수] = 신원준 = == 최대 힙 == {{{ (코드를 여기에) }}} == DFS와 BFS == {{{ (코드를 여기에) }}} == 네트워크 연결 == {{{ (코드를 여기에) }}} = 이민욱 = == 최대 힙 == {{{ #include int Heap[200000]; int idx=1; void push(int x); int pop(); void balance(int now_idx); int main() { int N, i, O; scanf("%d", &N); for(i=0;iHeap[now_idx/2]){ tmp = Heap[now_idx]; Heap[now_idx] = Heap[now_idx/2]; Heap[now_idx/2] = tmp; } balance(now_idx/2); } void balance_down(int now_idx){ int tmp, max_idx; if(now_idx>=idx) return; max_idx = Heap[now_idx*2]>Heap[now_idx*2+1] ? now_idx*2 : now_idx*2 +1; if(Heap[now_idx] #include using namespace std; int N, M, V; int Ver[1001][1001]={0}; int Ver1[1001][1001]={0}; int Already[1001]; queue q; void DFS(int Node); void BFS(); int main() { int A, B, i; scanf("%d %d %d", &N, &M, &V); for(i=0;i #include #define left_child(x) (2*x) #define right_child(x) (2*x+1) #define parent(x) (x/2) int heap[200001]; int index = 1; void push(int target); int pop(); void heap_maint(int cursor); void heap_chk(int cursor); void swap(int* a, int* b) { int temp; temp = *a; *a = *b; *b = temp; } int main() { int N, temp; scanf(" %d", &N); for (int i = 0; i < N; i++) { scanf(" %d", &temp); if (temp == 0) { printf("%d\n", pop()); } else { push(temp); } } return 0; } void push(int target) { heap[index] = target; heap_maint(index); index++; } int pop() { int foo; if (index == 1) { return 0; } foo = heap[1]; heap[1] = heap[index - 1]; heap[index - 1] = 0; heap_chk(1); index--; return foo; } void heap_maint(int cursor) { if (cursor == 1) { return; } if (heap[cursor] > heap[parent(cursor)]) { swap(&heap[cursor], &heap[parent(cursor)]); } heap_maint(parent(cursor)); } void heap_chk(int cursor) { if (cursor >= index) { return; } int max = heap[left_child(cursor)] > heap[right_child(cursor)] ? left_child(cursor) : right_child(cursor); if (heap[cursor] < heap[max]) { swap(&heap[cursor], &heap[max]); heap_chk(max); } } }}} == DFS와 BFS == {{{ (코드를 여기에) }}} == 네트워크 연결 == {{{ (코드를 여기에) }}}