Advertisement
Guest User

Untitled

a guest
Jan 11th, 2023
2,462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.28 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <set>
  4. #include <algorithm>
  5. #include <ctime>
  6. #include <cmath>
  7. #include <map>
  8. #include <assert.h>
  9. #include <fstream>
  10. #include <cstdlib>
  11. #include <random>
  12. #include <iomanip>
  13. #include <queue>
  14. #include <random>
  15. #include <unordered_map>
  16.  
  17. using namespace std;
  18.  
  19. #define sqr(a) ((a)*(a))
  20. #define all(a) (a).begin(), (a).end()
  21.  
  22. long long MOD = (int) 1e9 + 7;
  23.  
  24. void solve() {
  25.     int n;
  26.     cin >> n;
  27.  
  28.     vector<vector<int> > a(n);
  29.     map<int, int> occurrences;
  30.     for (int i = 0; i < n; ++i) {
  31.         int k;
  32.         cin >> k;
  33.  
  34.         a[i].resize(k);
  35.         for (int j = 0; j < k; ++j) {
  36.             cin >> a[i][j];
  37.             --a[i][j];
  38.  
  39.             ++occurrences[a[i][j]];
  40.         }
  41.     }
  42.  
  43.     for (int i = 0; i < n; ++i) {
  44.         bool find = false;
  45.         for (int j = 0; j < a[i].size(); ++j) {
  46.             if (occurrences[a[i][j]] == 1) {
  47.                 find = true;
  48.                 break;
  49.             }
  50.         }
  51.  
  52.         if (!find) {
  53.             cout << "Yes\n";
  54.             return;
  55.         }
  56.     }
  57.  
  58.     cout << "No\n";
  59. }
  60.  
  61. int main() {
  62.     // freopen("input.txt", "r", stdin);
  63.  
  64.     int tests = 1;
  65.     cin >> tests;
  66.  
  67.     for (int i = 1; i <= tests; ++i) {
  68.         solve();
  69.     }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement