on
[JAVA/자바 백준 14502] 연구소
[JAVA/자바 백준 14502] 연구소
반응형
https://www.acmicpc.net/problem/14502
풀이
dfs, bfs 문제입니다.
저는 우선 bfs로 풀었습니다.
1.
make_wall 함수를 만들어서
3개의 벽을 만들어주는 기능(combination)을 구현하구,
2.
조건을 만족하면 bfs 탐색을 했습니다.
--막힌 점
조합을 써야하는건 알았지만 2차원 배열에서 구현하는데 조금 시간어 걸렸습니다.
import java.io.*; import java.util.*; // bfs문제 // 벽을 만들 수 있는 갯수는 최대가 3개이므로 3개 디폴트 public class Main { static int n,m; static int[][] graph; static int[][] check; static Queue queue=new LinkedList(); static int[] dx= {0,0,1,-1}; static int[] dy= {1,-1,0,0}; static int max_val=0; public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st= new StringTokenizer(br.readLine(), " "); n = Integer.parseInt(st.nextToken()); m = Integer.parseInt(st.nextToken()); graph=new int[n][m]; check=new int[n][m]; for(int i=0;i
728x90
반응형
from http://kwangkyun-world.tistory.com/75 by ccl(A) rewrite - 2021-09-17 13:01:53