天天看点

Codeforces Round #736 (Div. 2) C. Web of Lies

​​传送门​​

Codeforces Round #736 (Div. 2) C. Web of Lies

题意:

思路:

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<string.h>
#include<map>
using namespace std;
#define ll long long

int fri[200010];

int main()
{
  int n,m;
  cin>>n>>m;
  while(m--)
  {
    int u,v;
    cin>>u>>v;
    fri[min(u,v)]++;
  }
  int ans = 0;
  for(int i = 1; i <= n; i++)
  if(!fri[i])ans++;
  int q;
  cin>>q;
  while(q--)
  {
    int op;
    cin>>op;
    int u,v;
    if(op == 1)
    {
      scanf("%d%d",&u,&v);
      fri[min(u,v)]++;
      if(fri[min(u,v)] == 1)ans--;
    }
    else if(op == 2)
    {
      scanf("%d%d",&u,&v);
      fri[min(u,v)]--;
      if(fri[min(u,v)] == 0)
      ans++;
    }
    else
    {
      cout<<ans<<"\n";
    }
    
  }
}