嗯我的做法听龊的
有在线做法,诶我强行用一大堆STL跑过去了
啥都写不好,一次没AC
/**************************************************************
Problem: 4419
User: di4CoveRy
Language: C++
Result: Accepted
Time:1664 ms
Memory:19996 kb
****************************************************************/
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#define N 500050
using namespace std;
struct Edge{int a,b,f,t;}e[N];
int n,m,x,y,cnt,ans[N];
char cmd[10];
vector<int> t[N];
int main() {
scanf("%d%d",&n,&m);
for (int _=1;_<=m;_++) {
scanf("%s",cmd+1);
if (cmd[1] == '!') {
scanf("%d",&x); t[x].push_back(_);
} else {
++cnt;
scanf("%d%d",&e[cnt].a,&e[cnt].b);
e[cnt].f = cmd[1] == '+' ? 1 : -1; e[cnt].t = _;
}
}
for (int _=1;_<=cnt;_++) {
#define A e[_].a
#define B e[_].b
#define F e[_].f
#define T e[_].t
ans[B] += F * (int)( t[A].end() - lower_bound(t[A].begin(),t[A].end(),T) );
ans[A] += F * (int)( t[B].end() - lower_bound(t[B].begin(),t[B].end(),T) );
}
for (int _=1;_<=n;_++) printf("%d%c",ans[_],_==n?'\n':' ');
return 0;
}