Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 7, 2017 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudelson/fc52237caf1e7a0d4026c53e0d5afff9 to your computer and use it in GitHub Desktop.
Save dudelson/fc52237caf1e7a0d4026c53e0d5afff9 to your computer and use it in GitHub Desktop.
My solution for UVA 10895
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
vector< vector< pair<int, int> > > t;
int n, m;
int main() {
while(cin >> m >> n) {
t.resize(n);
fill(t.begin(), t.end(), vector< pair<int, int> >());
for(int i=0; i<m; i++) {
int k;
cin >> k;
vector<int> idx(k), val(k);
for(auto &x: idx) cin >> x;
for(auto &x: val) cin >> x;
for(int j=0; j<k; j++)
t[idx[j]-1].push_back(make_pair(i+1, val[j]));
}
cout << n << " " << m << '\n';
for(auto v : t) {
cout << v.size();
for(int i=0; i<(int)v.size(); i++) {
cout << " " << v[i].first;
}
cout << '\n';
for(int i=0; i<(int)v.size(); i++) {
if(i > 0) cout << " ";
cout << v[i].second;
}
cout << '\n';
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment