-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForeverWinter.cpp
More file actions
42 lines (39 loc) · 881 Bytes
/
Copy pathForeverWinter.cpp
File metadata and controls
42 lines (39 loc) · 881 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
// https://codeforces.com/contest/1829/problem/F
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
void solveCase() {
int n, m;
cin >> n >> m;
vector<vector<bool>> graph(n+1, vector<bool>(n+1));
for (int i = 0, u, v; i < m; ++i) {
cin >> u >> v;
graph[u][v] = graph[v][u] = true;
}
int x = 0, y = 0;
for (int i = 1, edges; i <= n; ++i) {
edges = 0;
for (int j = 1; j <= n; ++j) {
edges += graph[i][j];
}
if (edges == 1) {
++y;
} else {
++x;
}
}
--x;
y /= x;
cout << x << " " << y << endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int nC = 1;
cin >> nC;
for (int i = 1; i <= nC; i++) {
// cout << "\nTEST #" << i << ":\n";
solveCase();
}
return 0;
}