코딩테스트 문제 풀이/[백준] DFS와 BFS(6)
-
C# 7576번 토마토
using System; using System.Collections.Generic; namespace _6 { class Program { static int N, M; //맵 저장 행렬 static int[,] map = new int[1001, 1001]; //방문 확인 행렬 static bool[,] visited = new bool[1001, 1001]; static int[,] disMap = new int[1001, 1001]; static Queue queue = new Queue(); static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; static void Reset() //초기화 { for (int i = 0; i..
2022.03.13 -
C# 2178번 미로 탐색
코드 : using System; using System.Collections.Generic; namespace _3 { class Program { static int N,M; //맵 저장 행렬 static int[,] map = new int[101, 101]; //방문 확인 행렬 static bool[,] visited = new bool[101, 101]; //시작점부터의 거리를 저장하는 행렬 static int[,] disMap = new int[101, 101]; static Queue queue = new Queue(); static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; static void Reset() //방문배열..
2022.03.12 -
C# 1012번 유기농 배추
코드 : using System; using System.Collections.Generic; namespace _4 { class Program { static int T,M,N,K; //맵 저장 행렬 static int[,] map = new int[51, 51]; //방문 확인 행렬 static bool[,] visited = new bool[51, 51]; static Queue queue = new Queue(); static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; //배추흰지렁이 수 static int count; static void Reset() //초기화 { count = 0; for (int i = 0; i < M..
2022.03.12 -
C# 2667번 단지번호붙이기
코드 : using System; using System.Collections.Generic; namespace _3 { class Program { static int N; //맵 저장 행렬 static int[,] map = new int[26, 26]; //단지내의 집의 수 저장 행렬 static int[] houseCount = new int[1000]; //방문 확인 행렬 static bool[,] visited = new bool[26,26]; static Queue queue = new Queue(); static int[] dx = { -1, 1, 0, 0 }; static int[] dy = { 0, 0, -1, 1 }; //단지수 static int count = 0; //단지내의 집수..
2022.03.04 -
C# 2606번 바이러스
코드 : using System; using System.Collections.Generic; namespace _2 { class Program { static int N; static int M; static int count; static public int[,] map = new int[101, 101]; static public bool[] visited = new bool[101]; static public Queue queue = new Queue(); static void Reset() { for (int i = 1; i
2022.03.04 -
C# 1260번 DFS와 BFS
코드 : using System; using System.Collections.Generic; namespace _1 { class Program { static int[] input; static int N; static int M; static int V; static public int[,] map = new int[1001, 1001]; static public bool[] visited = new bool[1001]; static public Queue queue = new Queue(); static public Stack stack = new Stack(); static void Reset() { for (int i = 1; i
2022.03.04