Search
Duplicate
📕

상근이의 여행

주차
문제번호
9372
언어
C++
티어
실버
유형
트리
그래프
MST
nj_Blog
nj_상태
이해도
33%
풀이
사람
이해도 2
13 more properties

문제접근

놓쳤던 부분

감각적으로 n - 1로 구하면 될 거라는 사실은 알았지만 MST의 개념에 대해서 공부를 해야함

코드

2020 KB

20 ms

#include <iostream> using namespace std; int main(void) { int t; int n, m; int a, b; ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> t; for (int i = 0; i < t; i++) { cin >> n >> m; for (int j = 0; j < m; j++) cin >> a >> b; cout << n - 1 << "\n"; } return (0); }
C++
복사