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
| #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <map> #include <set> using namespace std; typedef long long ll;
const int N = 201000;
int n, m, s; int cnt[N]; int ans[N];
int main() { cin >> n >> m >> s; int tt = 0; set<int> group[N]; while(s--) { int op, x, y; scanf("%d%d%d", &op, &x, &y); if(op == 1) { group[y].insert(x); ans[x] -= cnt[y]; } else if(op == 2) { group[y].erase(x); ans[x] += cnt[y]; } else if(op == 3) { cnt[y]++; ans[x]--; } } for(int i = 1; i <= n; i++) { for(auto it:group[i]) ans[it] += cnt[i]; } for(int i = 1; i <= m; i++) { printf("%d\n", ans[i]); }
return 0; }
|