목록백준 (51)
안선생의 개발 블로그
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #include #include #include using namespace std; bool visit[1000001] = { 0 }; int f, s, g, u, d; int cnt = 0; void bfs(int x) { queue a; a.push({ x,0 }); visit[x] = 1; while (!a.empty()) { int xx = a.front().first; cnt = a.front().second; if (xx == g) { cout s >> ..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 #include #include #include #include #include #include using namespace std; int g[1001][1001] = { 0 }; bool visit[1001][1001] = { 0 }; int dx[4] = { 0,1,-1,0 }; int dy[4] = {..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 #include #include #include #include #include #include using namespace std; int g[1001][1001] = { 0 }; bool visit[1001][1001] = { 0 }; int dx[4] = { 0,1,-1,0 }; int dy[4] = { 1,0,0,-1 }; int n, m, w..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 #include #include #include #include #include #include using namespace std; char g[111][111] = { 0 }; bool visit[111][111] = {0}; int dx[4] = { 0,1,-1,0 }; int dy..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 #include #include #include #include #include using namespace std; int n, m, k = 0, e = 0; int bfs(int x) { queue a; a.push({ x,1 }); while (!a.empty()) { long long xx = a.front().first; int c = a.front().second; a.pop(); if (xx == m) return c; if (xx * 2 n >> m; cout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 #include #include #include #include #include using namespace std; char g[111][111] = { 0 }; bool visit[111][111] = { 0 }; int dx[4] = { 0,1,-1,0 }; int dy[4] = { 1,0,0,-1 }; int n, m, k; void bfs(int x, int..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 #include #include #include #include using namespace std; int g[501][501] = {0}; bool visit[501][501] = {0}; int dx[6] = { -2,-2,0,0,2 ,2}; int dy[6] = { -1,1,-2,2 ,-1,1}; int n, m,k,r1,r2,c1,c2; int wolf = 0; int sheep = 0; int bfs(int x,int y) { queue a; a..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 #include #include #include #include using namespace std; char g[501][501] = {0}; bool visit[501][501] = {0}; int dx[4] = { 0,1,-1,0 }; int dy[4] = { 1,0,0,-1 }; int n, m,k; ..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 #include #include #include #include #include #include using namespace std; int arr[200000] ={0}; int n, m,k; int bfs(int x) { if (x == k) return 0; queue a; a.push(x); while (!a.empty()) { int x1 = a.front(); a.pop(); if (x1 == k) { return arr[x..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 #include #include #include #include #include using namespace std; int g[502][502] = {}; int chess[502][502] = {}; bool visit[502][502] = {}; int n, m,k; int a, b, c, d; // 오 아 왼 위 int dx[8] = { 2,1,2,1,-2,-1,-2,-..