문제 바로가기> 백준 9372번: 상근이의 여행
비행 스케줄은 연결 그래프를 이루고 이미 방문한 국가도 거칠 수 있다.
따라서 항상 N-1개의 경우가 최소이다.
#include <iostream>
using namespace std;
int main(){
int t; cin>>t;
int n, m;
int a, b;
for(int i=0; i<t; i++){
cin >> n >> m;
for(int j=0; j<m; j++)
cin >> a >> b;
cout << n-1 << '\n';
}
}