본문 바로가기

백준51

C++ 13565 침투 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.. 2023. 2. 25.
C++ 1303 전쟁 - 전투 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.. 2023. 2. 25.
C++ 16953 A ->B 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 2023. 2. 25.
C++ 11123 양 한마리... 양 두마리... 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.. 2023. 2. 24.
C++ 16948 데스나이트 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.. 2023. 2. 24.
C++ 3184 양 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; .. 2023. 2. 24.