-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathABC_177_D.cpp
More file actions
48 lines (40 loc) · 847 Bytes
/
ABC_177_D.cpp
File metadata and controls
48 lines (40 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>
using namespace std;
typedef long long ll;
void dfs(int curr, vector<vector<int>>& v,
vector<bool>& visited, int &cnt) {
if (visited[curr]) return;
visited[curr] = true;
cnt++;
for (int i = 0; i < v[curr].size(); i++) {
dfs(v[curr][i], v, visited, cnt);
}
}
int main() {
int N, M;
cin >> N >> M;
vector<vector<int>> v(N + 1);
for (int i = 0; i < M; i++) {
int a, b;
cin >> a >> b;
v[a].push_back(b);
v[b].push_back(a);
}
vector<bool> visited(N + 1);
int ans = 0;
for (int i = 1; i <= N; i++) {
int cnt = 0;
dfs(i, v, visited, cnt);
ans = max(ans, cnt);
}
cout << ans << endl;
}