Sreekar_0125

Untitled

Sep 25th, 2023
955
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. void solve()
  2. {
  3.     int n;
  4.     cin >> n;
  5.  
  6.     si total;
  7.     vector<vi> sets(n);
  8.  
  9.     f(i, 0, n)
  10.     {
  11.         int x;
  12.         cin >> x;
  13.  
  14.         while(x--)
  15.         {
  16.             int y;
  17.             cin >> y;
  18.             sets[i].pb(y);
  19.             total.insert(y);
  20.         }
  21.  
  22.         sort(all(sets[i]));
  23.     }
  24.     int maxans = -1;
  25.     for(auto ele : total)
  26.     {
  27.         si aux;
  28.         f(i, 0, n)
  29.         {
  30.             if(!binary_search(all(sets[i]), ele))
  31.             {
  32.                 for(auto j : sets[i])
  33.                 {
  34.                     aux.insert(j);
  35.                 }
  36.             }
  37.         }
  38.         maxans = max(maxans, (int)aux.size());
  39.     }
  40.     println(maxans);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment