Advertisement
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--)
- int main()
- {
- _test
- {
- int n;
- cin>>n;
- vector<vector<int>> v(n);
- vector<int> cnt(100);
- for(int i=0; i<n; i++)
- {
- int k;
- cin>>k;
- v[i].resize(k);
- for(auto &e: v[i]) cin>>e;
- for(auto e: v[i]) cnt[e]++;
- }
- int ans = 0;
- vector<int> cnt2(100);
- for(int i=0; i<100; i++)
- {
- if(!cnt[i]) continue;
- fill(cnt2.begin(), cnt2.end(), 0);
- for(int j=0; j<n; j++)
- {
- if(binary_search(v[j].begin(), v[j].end(), i)) continue;
- for(auto e: v[j]) cnt2[e] = 1;
- }
- ans = max(ans, accumulate(cnt2.begin(), cnt2.end(), 0));
- }
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement