BOJ

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

180131_7562_나이트의 이동

//https://www.acmicpc.net/problem/7562#include #include using namespace std;int map[300][300];int sy,sx,dy,dx, I; int diry[8]={2,2,1,1,-1,-1,-2,-2};int dirx[8]={-1,1,-2,2,-2,2,-1,1}; void bfs(int starty, int startx){ queue q; q.push(starty*1000+startx); map[starty][startx]=1; bool chk=1; while(chk && !q.empty()){ int nowy=q.front()/1000; int nowx=q.front()%1000; q.pop(); for(int i=0; i=0 && next..

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

180131_2293_동전1

//https://www.acmicpc.net/problem/2293 #include using namespace std;int dp[10001];int value[101]; int main(){ int n, k; cin >> n >> k; for(int i=0; i> value[i]; dp[0]=1; for(int i=0; i=5이므로 계산에 포함 x

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

180131_2644_촌수계산

//https://www.acmicpc.net/problem/2644 #include #include #include using namespace std;int parent[101]; // parent[i] :: i의 부모int chon[101];int n; void bfs(int start){ queue q; q.push(start); chon[start]=0; while(!q.empty()) { int now=q.front(); q.pop(); for(int i=1; i> n >> a >> b >> m; for(int i=0; i> x >> y; parent[y]=x;//y의 부모가 x } memset(chon, -1, sizeof(chon)); bfs(a); cout

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

180130_10026_적록색약

//https://www.acmicpc.net/problem/10026 #include #include using namespace std;char picture[100][100];bool visit[100][100];bool visitbi[100][100];int n, cnt;int dy[4]={1,-1,0,0};int dx[4]={0,0,-1,1}; void dfs(int y, int x, char c){ visit[y][x]=1; for(int i=0; i=0 && ny=0 && nx> n; //input for(int i=0; i> picture[i]; for(int i=0; i

bong sue
'BOJ' 태그의 글 목록 (14 Page)