解法一:模拟
#include <bits/stdc++.h>using namespace std;vector<vector<string>> info;int main() {ios::sync_with_stdio(false);cin.tie(0);int N, K;cin >> N >> K;info.resize(K);string name;int M, tmp;for (int i = 0; i < N; ++i) {cin >> name;cin >> M;for (int j = 0; j < M; ++j) {cin >> tmp;info[tmp - 1].emplace_back(name);}}int i = 1;for (auto &list:info) {cout << i << " " << list.size() << "\n";++i;sort(list.begin(), list.end());for (auto &student:list) {cout << student << "\n";}}}
