Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <vector>
- #include <list>
- #include <algorithm>
- using namespace std;
- vector<list<int> > g;
- int n;
- void read(){
- scanf("%d", &n);
- g.resize(n, list<int>());
- int m, t;
- for (int i = 0; i < n; i++){
- scanf("%d", &m);
- for (int j = 0; j < m; j++){
- scanf("%d", &t);
- --t;
- g[t].push_back(i);
- }
- }
- }
- void solve(){
- for (int i = 0; i < n; i++){
- printf("%d ", g[i].size());
- g[i].sort();
- g[i].unique();
- while (g[i].size() != 0){
- printf("%d ", g[i].front() + 1);
- g[i].pop_front();
- }
- printf("\n");
- }
- }
- int main(){
- freopen("input.txt", "r", stdin);
- read();
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement