BOJ 백준/Class 4
백준 1967번, 트리의 지름(C, C++)
https://www.acmicpc.net/problem/1967 #include #include #include #define MAX 10001 using namespace std; vectorv[MAX]; bool visited[10001] = {false}; int ans = 0; int endpoint = 0; void dfs(int num, int length){ if(visited[num]){ return; } visited[num] = true; if(ans < length){ ans = length; endpoint = num; } for(int i = 0; i < v[num].size(); i++){ int next = v[num][i].first; int cost = v[num][i]...