fork download
  1. #include <iostream>
  2. using namespace std;
  3. int n,arr[105][105],t[105][105],l[105];
  4. int main() {
  5. cin>>n;
  6. for(int i=1;i<=n;i++){
  7. int k;
  8. cin>>k;
  9. for(int j=1;j<=k;j++){
  10. cin>>arr[i][j];
  11. t[arr[i][j]][l[arr[i][j]]+1]=i;
  12. l[arr[i][j]]++;
  13. }
  14. }
  15. for(int i=1;i<=n;i++){
  16. cout<<l[i]<<" ";
  17. for(int j=1;j<=l[i];j++){
  18. cout<<t[i][j]<<" ";
  19. }
  20. cout<<"\n";
  21. }
  22. return 0;
  23. }
Success #stdin #stdout 0s 5312KB
stdin
7
1 3
4 3 4 6 7
1 7
3 2 6 7
2 3 7
1 4
1 5
stdout
0 
1 4 
3 1 2 5 
2 2 6 
1 7 
2 2 4 
4 2 3 4 5