AcWing 5719. 词频统计
原题链接
简单
作者:
νοιδ
,
2024-07-24 08:46:18
,
所有人可见
,
阅读 15
考场写的,来这里贴一下
#include <iostream>
#include <set>
using namespace std;
const int M = 110;
int cnt1[M], cnt2[M];
int n, m, l;
int a;
set<int> has;
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i ++ ){
cin >> l;
has.clear();
for (int j = 0; j < l; j ++ ){
cin >> a;
has.insert(a);
cnt2[a]++;
}
set<int>::iterator it;
for (it = has.begin(); it != has.end(); it ++) cnt1[*it] ++;
}
for (int i = 1; i <= m; i ++){
cout << cnt1[i] << ' ' << cnt2[i] << endl;
}
return 0;
}