[C++] 백준 2468번: 안전 영역
#include #include #include #include using namespace std; int arr[101][101]; bool visit[101][101]; int dx[] = { 1,-1,0,0 }, dy[] = { 0,0,1,-1 }; int n, height[101]; void dfs(int x, int y, int h) { visit[x][y] = true; for (int i = 0; i = 0 && nx = 0 && ny h) { dfs(nx, ny, h); } } } int main() { ..
2021. 9. 12.
[C++] 백준 20046번: Road Reconstruction
#include #include #include #define MAX 1e9 using namespace std; int m, n; int dis[1001][1001]; int adj[1001][1001]; int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 }; int visit[1001][1001]; void dijkstra(int a, int b) { fill(&dis[0][0], &dis[1000][1001], MAX); priority_queue pq; if (adj[a][b] != -1) { dis[a][b] = adj[a][b]; pq.push({ -dis[a][b], {a,b} }); } while (!pq.empty()) { int c = -pq.top().f..
2021. 9. 9.