Ankit_132

B

Aug 13th, 2023 (edited)
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.15 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define ll     long long
  6. #define _test  int _TEST; cin>>_TEST; while(_TEST--)
  7. #define pb     push_back
  8.  
  9. int main()
  10. {
  11.     ios_base::sync_with_stdio(false);
  12.     cin.tie(NULL);
  13.     cout.tie(NULL);
  14.  
  15.     int n;
  16.     cin>>n;
  17.  
  18.     vector<vector<int>> a;
  19.     vector<int> b;
  20.  
  21.     for(int i=0; i<n; i++)
  22.     {
  23.         int c;
  24.         cin>>c;
  25.  
  26.         b.resize(c);
  27.         for(auto &e: b)
  28.             cin>>e;
  29.  
  30.         a.pb(b);
  31.     }
  32.  
  33.     int x;
  34.     cin>>x;
  35.  
  36.     vector<int> ans;
  37.     int few = 1e9;
  38.     int tmp;
  39.  
  40.     for(int i=0; i<n; i++)
  41.     {
  42.         int f = 0;
  43.  
  44.         for(auto e: a[i])
  45.         {
  46.             if(e == x)
  47.             {
  48.                 f = 1;
  49.                 tmp = a[i].size();
  50.                 break;
  51.             }
  52.         }
  53.  
  54.         if(f)
  55.         {
  56.             if(tmp == few)
  57.                 ans.pb(i+1);
  58.             else if(tmp < few)
  59.             {
  60.                 ans.clear();
  61.                 ans.pb(i+1);
  62.                 few = tmp;
  63.             }
  64.         }
  65.     }
  66.  
  67.     cout<<ans.size()<<"\n";
  68.     for(auto e: ans)
  69.         cout<<e<<" ";
  70.     cout<<"\n";
  71. }
  72.  
Advertisement
Add Comment
Please, Sign In to add comment