AcWing 5719. 词频统计
原题链接
简单
作者:
一二爱上蜜桃猫.
,
2024-10-26 16:53:52
,
所有人可见
,
阅读 3
#include<bits/stdc++.h>
using namespace std;
const int N = 101;
int n, m;
int a[N];
bool b[N][N];
int word[N][N];
int main()
{
cin >> n >> m;
for(int i = 1; i <= n; i ++)
{
int l;
cin >> l;
for(int j = 1; j <= l; j ++)
{
cin >> word[i][j];
a[word[i][j]] ++;
b[i][word[i][j]] = true;
}
}
for(int i = 1; i <= m; i ++)
{
int sum = 0;
for(int j = 1; j <= n; j ++)
{
if(b[j][i])
{
sum ++;
}
}
cout << sum << " " << a[i] << endl;
}
return 0;
}