-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1320.cpp
More file actions
46 lines (44 loc) · 905 Bytes
/
1320.cpp
File metadata and controls
46 lines (44 loc) · 905 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
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <stack>
using namespace std;
int main()
{
vector<vector<int>> n(1001);
vector<bool> v(1000, false);
int x, y;
while (scanf("%d %d", &x, &y) != EOF)
{
n[x].push_back(y);
n[y].push_back(x);
}
for (int i = 1; i < 1000; i++)
{
std::stack<int> s;
if (v[i])
continue;
s.push(i);
int c = 0;
while (!s.empty())
{
auto i = s.top();
s.pop();
v[i] = true;
for (auto it = n[i].begin(); it < n[i].end(); it++)
{
if (v[*it])
continue;
c++;
s.push(*it);
}
}
if (c % 2)
{
cout << "0";
return 0;
}
}
cout << "1";
return 0;
}