171119_11724_연결 요소의 개수
#include using namespace std;int N, M;bool map[1002][1002];bool visit[1001]; void dfs(int y){ visit[y]=1; for(int i=1; i> N >> M; for(int i=0; i> u >> v; map[u][v]=1; map[v][u]=1; } for(int i=1; i
#include using namespace std;int N, M;bool map[1002][1002];bool visit[1001]; void dfs(int y){ visit[y]=1; for(int i=1; i> N >> M; for(int i=0; i> u >> v; map[u][v]=1; map[v][u]=1; } for(int i=1; i
#include using namespace std;int map[102][102];bool visit[102][102];int N; int dx[4]={1, -1, 0, 0};int dy[4]={0, 0, 1, -1}; void dfs(int y, int x, int r_height){ visit[y][x] = 1; for(int i=0; i0 && !visit[ny][nx]) { dfs(ny, nx, r_height); } }} int main(){ int m_height=0; int m_area=1; cin >> N; /*input*/ for(int i=1; i map[i][j]; if(m_height
#include #include using namespace std;bool map[100][100] ;bool visit[100][100];int v[5000];int n_area;int nv;int M, N, K; int dx[4]={ 1, -1, 0, 0};int dy[4]={ 0, 0, 1, -1}; void dfs(int y, int x){nv++; //넓이for(int i=0; i=0 && ny=0 && nx> M >> N >> K; /*input*/for (int i = 0; i < K; i++){int x1, y1, x2, y2;cin ..
#include using namespace std; int map[22][22];bool visit[27];//A=1, B=2, C=3,... ,Z=26int cnt; int dx[4] = { 1,-1,0,0 };int dy[4] = { 0,0,1,-1 }; void dfs(int y, int x, int curr){int N=0; for (int i = 0; i0 && !visit[map[ny][nx]]){visit[map[ny][nx]] = 1;dfs(ny, nx,map[ny][nx]);visit[map[ny][nx]] = 0;}}for(int i=1; i R >> C; //inputfor (int i = 0; i > str;for (int j = ..