hiho week 49 register

Ended

Participants:509

Verdict:Accepted
Score:100 / 100
Submitted:2015-06-07 14:49:43

Lang:G++

Edit
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
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
using namespace std;
vector<int> father;
vector<int> degree;
int N, M;
int u, v;
int findFather(int x) {
    while (x != father[x]) x = father[x];
    return x;
}
bool isOK() {
    int cnt = 0;
    for (int i = 1; i <= N; ++i) if (father[i] == i) ++cnt;
    if (cnt != 1) return false;
    cnt = 0;
    for (int i = 1; i <= N; ++i) if (degree[i] & 1) {
        ++cnt;
        if (cnt > 2) return false;
    }
    return true;
}
int main() {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX