개발자 톡

연습문제 톡 징검다리

징검다리1 반례 부탁드립니다.

등록일
2021-10-08 10:53:35
조회수
1164
작성자
algoalgo

시간 초과는 이해가 되는데,

반례는 잘 모르겠습니다.


public class Main
{
	static int[] bridge;
	static int n;
	static int maxCnt = 0;
	
    public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		n = Integer.parseInt(st.nextToken());
		bridge = new int[n];
		
		st = new StringTokenizer(br.readLine());
		for(int i=0; i maxCnt) {
				maxCnt = count;
			}
			return;
		}
		for(int i=start; i curr) {
				dfs(bridge[i], i+1, count+1);
			}
		}
	}
}


#징검다리
#java

이 카테고리의 톡 더보기