코딩테스트/백준

    [실2] 11724 - 연결 요소의 개수

    Dfs로 주변 정점이 있는지 파악하고 있을 시 방문 여부 표시 없을 시 새로운 그래프로 간주 후 1개 증가 #include #include #include #include using namespace std;#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0);#define y first#define x secondusing IntPair = pair;IntPair dir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우};vector> graph;vector vis;int n, m;void Dfs(int idx){ vis[idx] = true; for (int i = 0; i > n >> m; ..

    [실2] 1012 - 유기농 배추

    x y로 푸는 사람들한텐 안맞을듯 #include #include #include using namespace std;#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0);pair dir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우};vector> map;int t, h, w, k;void Dfs(int y, int x){ for (int i = 0; i = h || ny = w || nx > t; while (t--) { int cnt = 0; cin >> h >> w >> k; map = vector>(h, vector(w)); while (k--) { int a, b;..

    [실2] 4963 - 섬의 개수

    #include #include using namespace std;#define FAST_IO() ios::sync_with_stdio(0); cin.tie(0);pair dir[]{ {1, 0}, // 상 {-1, 0}, // 하 {0, -1}, // 좌 { 0, 1 }, // 우 // 대각선 {1, 1}, {-1, -1}, {1, -1}, {-1, 1},};vector> map;int h, w;void Dfs(int y, int x){ for (int i = 0; i = h || ny = w || nx > w >> h; if (!w && !h) break; //map.resize(h, vector(w)); map = vector>(h, vector(w)); for (i..