-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCF723E.cpp
More file actions
67 lines (65 loc) · 1.29 KB
/
CF723E.cpp
File metadata and controls
67 lines (65 loc) · 1.29 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include<bits/stdc++.h>
using namespace std;
using pll = pair<long long,long long>;
using pii = pair<int,int>;
const int MAXN = 1e6 + 50000;
const int mod = 1e9 + 7;
vector<int>g[205];
set<pair<int,int>>st;
int v[205];
int n;
void dfs(int now) {
v[now] = 1;
while (g[now].size()) {
int x = g[now].back();
g[now].pop_back();
if (!st.count({x,now})) {
st.insert({now,x});
st.insert({x,now});
dfs(x);
if (max(now,x) != n + 1) {
cout << now <<' '<<x<<'\n';
}
}
}
}
void solve() {
st.clear();
int m;
cin >> n >> m;
for (int i = 1; i <= n + 1; i++) {
g[i].clear();
v[i] = 0;
}
for (int i = 0; i < m; i++) {
int x, y;
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
int ans = 0;
for (int i = 1; i <= n; i++) {
if (g[i].size() % 2) {
g[n+1].push_back(i);
g[i].push_back(n+1);
}
else {
ans++;
}
}
cout << ans << '\n';
for (int i = 1; i <= n; i++) {
if (!v[i]) {
dfs(i);
}
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
}