백준

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

180207_2606_바이러스

//https://www.acmicpc.net/problem/2606 #include #include using namespace std;int N, M, cnt;bool network[101][101];bool visited[101]; void input(){ cin >> N >> M; int a,b; for(int i=0; i> a >> b; network[a][b]=network[b][a]=1; }} void bfs(){ queue q; q.push(1); visited[1]=1; while(!q.empty()){ int now=q.front(); q.pop(); for(int i=2; i

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

180206_5014_스타트링크

//https://www.acmicpc.net/problem/5014 #include #include using namespace std;int BD[1000001];int F,S,G,U,D;int mn=10000003; bool bfs(){ queue q; q.push(S); BD[S]=1; while(!q.empty()){ int now=q.front(); q.pop(); if(now==G){ if(mn>BD[now]) mn=BD[now]; return true; } int nu=now+U; int nd=now-D; if(nu>0 && nu0 && nd> F >> S >> G >> U >> D; if(bfs()) cout

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

180205_2589_보물섬

//https://www.acmicpc.net/problem/2589 #include #include #include using namespace std;char map[50][50];int visited[50][50];int N,M, mx; int dy[4]={0,0,1,-1};int dx[4]={1,-1,0,0}; void init(){ for(int i=0; imx) mx=visited[ny][nx]; } } } }} int main(){ cin >> N >> M; for(int i=0; i> map[i]; for(int i=0; i

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

180203_1010_다리 놓기

//https://www.acmicpc.net/problem/1010 #include using namespace std;int dp[31][31]; int main(){ int t; cin >> t; while(t-->0){ int n, m; cin >> n >> m; for(int i=1; i

bong sue
'백준' 태그의 글 목록 (15 Page)