forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
(CODEFORCES)web_of_lies.cpp
55 lines (45 loc) · 1.05 KB
/
(CODEFORCES)web_of_lies.cpp
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
#include<bits/stdc++.h>
using namespace std;
int die[2001007];
int main() {
int n, m, q, ans;
cin >> n >> m;
ans = n;
for(int i = 1; i <= m; i++) {
int a, b;
cin >> a >> b;
if(a < b) swap(a, b);
die[b]++;
if(die[b] == 1) ans--;
}
cin >> q;
for(int i = 1; i <= q; i++) {
int a, b, c;
cin >> a;
switch(a) {
case 3 : {
cout << ans << endl;
break;
}
case 1 : {
cin >> b >> c;
if(c > b) {
swap(b, c);
}
die[c]++;
if(die[c] == 1) ans--;
break;
}
case 2 : {
cin >> b >> c;
if(c > b) {
swap(b, c);
}
die[c]--;
if(die[c] == 0) ans++;
break;
}
}
}
return 0;
}