### 题目链接

https://codeforces.com/contest/1229/problem/C

### 题解

2400 的题我都不会……不过我真的觉得这题的复杂度分析神乎其神/kel

### 代码

#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reverse_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
int x = 0,f = 1; char ch = getchar();
for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
return x*f;
}

const int mxN = 1e5;
int n,en,m,q;
vector<int> ine[mxN+3];
int ind[mxN+3],oud[mxN+3];
int a[mxN+3];

int main()
{
n = read(),m = read();
for(int i=1; i<=m; i++) {int u = read(),v = read(); if(u<v) {swap(u,v);} ine[v].push_back(u); ind[v]++,oud[u]++;}
llong ans = 0ll; for(int i=1; i<=n; i++) ans += 1ll*ind[i]*oud[i];
printf("%lld\n",ans);
q = read();
while(q--)
{
int u = read(); ans -= 1ll*ind[u]*oud[u];
for(int i=0; i<ine[u].size(); i++)
{
int v = ine[u][i];
ine[v].push_back(u);
ans -= 1ll*ind[v]*oud[v]; ind[v]++,oud[v]--,ind[u]--,oud[u]++; ans += 1ll*ind[v]*oud[v];
}
ine[u].clear();
printf("%lld\n",ans);
}
return 0;
}