fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int t,x,n,k,a, arr[1001]={0,};
  7.  
  8. cin>>t>>x>>n;
  9.  
  10. for(int i=0;i<n;i++){
  11. cin>>k;
  12.  
  13. for(int j=0;j<k;j++){
  14. cin>>a;
  15. arr[a]++;
  16. }
  17. }
  18.  
  19. if(arr[x]==n)
  20. cout<<"YES";
  21. else
  22. cout<<"NO";
  23.  
  24. return 0;
  25. }
Success #stdin #stdout 0s 5316KB
stdin
7 3
4
1
4
6
1 2 4 5 6 7
3
1 3 4
2
4 7
stdout
NO