【題目敘述】https://vjudge.net/problem/UVA-10895
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
int m, n, a, b;
vector <int> idx;
map <int, vector<pair<int, int> > > mp;
set <int> st;
int main() {
while (cin >> m >> n){
mp.clear();
st.clear();
for (int i = 1; i <= m; i++){
cin >> a;
idx.clear();
for (int j = 0; j < a; j++){
cin >> b;
idx.push_back(b);
mp[b].push_back({i, 0});
st.insert(b);
}
for (int j = 0; j < a; j++){
cin >> b;
mp[idx[j]].back().second = b;
}
}
cout << n << " " << m << "\n";
int pre = 0;
for (auto i:st){
pre++;
while (pre < i){
cout << "0\n\n";
pre++;
}
cout << mp[i].size();
for (int j = 0; j < mp[i].size(); j++){
cout << " " << mp[i][j].first;
}
cout << "\n";
cout << mp[i][0].second;
for (int j = 1; j < mp[i].size(); j++){
cout << " " << mp[i][j].second;
}
cout << "\n";
}
while (pre < n){
cout << "0\n\n";
pre++;
}
}
}