- P37's solution
-
P37's Solution
- @ 2025-9-4 21:59:22
直接先统计每种宗教的信仰人数再统一累加即可。
#include <bits/stdc++.h>
using namespace std;
int a[1000012], b[1000012];
int main()
{
ios::sync_with_stdio(0);
int n, m, k;
cin >> n >> m >> k;
for (int i = 1; i <= n; i++)
{
int x;
cin >> x;
a[x]++;
}
for (int i = 1; i <= m; i++)
{
int s;
cin >> s;
while (s--)
{
int x;
cin >> x;
b[x] += a[i];
}
}
for (int i = 1; i <= k - 1; i++)
cout << b[i] << ' ';
cout << b[k] << endl;
return 0;
}