Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- #define pb push_back
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- int n;
- cin>>n;
- vector<vector<int>> a;
- vector<int> b;
- for(int i=0; i<n; i++)
- {
- int c;
- cin>>c;
- b.resize(c);
- for(auto &e: b)
- cin>>e;
- a.pb(b);
- }
- int x;
- cin>>x;
- vector<int> ans;
- int few = 1e9;
- int tmp;
- for(int i=0; i<n; i++)
- {
- int f = 0;
- for(auto e: a[i])
- {
- if(e == x)
- {
- f = 1;
- tmp = a[i].size();
- break;
- }
- }
- if(f)
- {
- if(tmp == few)
- ans.pb(i+1);
- else if(tmp < few)
- {
- ans.clear();
- ans.pb(i+1);
- few = tmp;
- }
- }
- }
- cout<<ans.size()<<"\n";
- for(auto e: ans)
- cout<<e<<" ";
- cout<<"\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment