그래프

알고리즘 문제 풀이/1DP_과제(~180615)

180522_4963_섬의 개수

//https://www.acmicpc.net/problem/4963 #include #include #include using namespace std; bool map[50][50];bool visited[50][50];int cnt;int w, h;int dy[8]={-1, -1, -1, 0, 0, 1, 1, 1};int dx[8]={-1, 0, 1, -1, 1, -1, 0, 1};void bfs(int y, int x){ queue q; q.push(make_pair(y,x)); map[y][x]=0; int nowy; int nowx; while(!q.empty()){ nowy=q.front().first; nowx=q.front().second; q.pop(); for(int i=0; i> w..

알고리즘 문제 풀이/1DP_과제(~180615)

180424_1068_트리

//https://www.acmicpc.net/problem/1068 #include #include using namespace std; int tree[50][50];//tree[i][0] : i 번째 노드의 자식 수 //tree[i][j] : i번째 노드의 자식 indexint n, d, ans;void search(int tmp);int main(){ cin >> n; int root; for(int i=0; i> p; if(p==-1) root=i; else{ tree[p][0]++; tree[p][tree[p][0]]=i; } } cin >> d; if(root==d) { cout

bong sue
'그래프' 태그의 글 목록