Skip to content

Instantly share code, notes, and snippets.

@zarc1411
Created April 17, 2020 06:47
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 zarc1411/6b199969df0af93fa782964b254a2dac to your computer and use it in GitHub Desktop.
Save zarc1411/6b199969df0af93fa782964b254a2dac to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
map<int , vector<int> > mp;
for(int i = 1 ; i<=n ; i++){
int x;
cin>>x;
for(int j = 0 ; j<x ; j++){
int type;
cin>>type;
mp[type].push_back(i);
}
}
int q;
cin>>q;
for(int i = 0 ; i<q ; i++){
int x;
cin>>x;
vector<int> v = mp[x];
if(v.size() == 0){
cout<<"None ";
}
else{
set<int> s;
for(int i = 0 ; i<v.size() ; i++){
s.insert(v[i]);
}
for(auto it = s.begin() ; it!=s.end() ; it++){
cout<<*it<<" ";
}
}
cout<<"\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment