WookjeBlog
    • 블로그
    • 소개
    • 태그
    • 수업/강의
    • 라이브러리
    Main
    • Share to Facebook

    서로소 집합

    All Posts in disjoint-set

    • [BOJ] 2162 : 선분 그룹

      2162 : 선분 그룹 풀이 선분이 교차하면 묶어주면 된다 코드 #include <bits/stdc++.h> #define fst first #define snd second using namespace std; typedef pair<int, int> pi; int n, par[3003], cnt[3003]; pi p[6003]; int ccw(pi a, pi b, pi c) { int r = a.fst*b.snd + b.fst*c.snd + c.fst*a.snd; r -= a.snd*b.fst + b.snd*c.fst + c.snd*a.fst; if (r > 0) return 1; if (r < 0) return -1; return 0; } int iscross(pi a, pi b, pi...

      boj ccw disjoint-set union-find

      wookje.kwon's profile image

      wookje.kwon

      2019-05-19 23:40

    • [BOJ] 16168 : 퍼레이드

      16168 : 퍼레이드 풀이 degree 짝수가 어쩌구 저쩌구 해서 풀어도 되는데 그냥 제곱 돌려도 된다. 근데 degree 어쩌구 저쩌구 할 때 유의해야 할 점은 connected graph가 아닐 수도 있어서 유니온파인드 같은 걸 해줘야한다. 잘 짜주면 된다. 코드 #include <cstdio> #include <cstdlib> #include <vector> using namespace std; int n, m, chk[3003][3003]; vector<int> gph[3003]; void dfs(int now, int num, int cnt) { if (cnt == m) { puts("YES"); exit(0); } for (int nxt : gph[now]) { if...

      boj scal-mookja graph dfs disjoint-set union-find

      wookje.kwon's profile image

      wookje.kwon

      2018-10-01 09:47

    • [BOJ] 3108 : 로고

      3108 : 로고 풀이 사각형을 하나의 노드로 보자. 어떤 두 사각형 a, b가 겹친다면 두 사각형은 연결된 것으로 생각하자. 연결된 사각형들은 연필을 들지 않고 삥삥 돌며 잘 그릴 수 있다. 연필은 연결 요소의 개수 - 1번 들어주면 된다. 단, 시작점인 (0, 0)을 지나는 경우의 예외처리를 잘 해주자. (x1=0, y1=0, x2=0, y2=0)인 경우도 비교해주면 된다. Flood fill로 풀어도 된다. 코드 #include <cstdio> #include <algorithm> #define y1 fu using namespace std; const int n_ = 1000 +...

      boj disjoint-set union-find dfs bfs flood-fill

      wookje.kwon's profile image

      wookje.kwon

      2018-04-06 19:10

    • github
    • facebook
    • rss

    Copyright © Wookje Kwon. All rights reserved.