题目描述
出题真简单
正着出一道 反正还能出一道
C++ 代码
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main()
{
cin >> n >> k;
unordered_map<string, vector<int>> m;
while (k --)
{
int i, ni;
cin >> i >> ni;
while (ni --)
{
string name;
cin >> name;
m[name].push_back(i);
}
}
string name;
while (cin >> name)
{
cout << name << " " << m[name].size() << " ";
sort(m[name].begin(), m[name].end());
for (auto i : m[name]) cout << i << " ";
cout << endl;
}
}