Saleh127

LO 1261.cpp

Jun 29th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. int main()
  6. {
  7. ll t,rr;
  8. cin>>t;
  9. for(rr=1;rr<=t;rr++)
  10. {
  11. ll c=0,n,m,k,i,j,l,p,x;
  12. ll a[500][500];
  13. ll check[500]={0};
  14. cin>>n>>m>>k;
  15. for(i=0;i<n;i++)
  16. {
  17. for(j=0;j<k;j++)
  18. {
  19. cin>>a[i][j];
  20. }
  21. }
  22. cin>>p;
  23. for(i=0;i<p;i++)
  24. {
  25. cin>>x;
  26. check[x]=1;
  27. }
  28. for(i=0;i<n;i++)
  29. {
  30. l=0;
  31. for(j=0;j<k;j++)
  32. {
  33. x=a[i][j];
  34. if(x>0 && check[x]==1)
  35. {
  36. l=1;
  37. }
  38. else if(x<0 && check[-x]==0)
  39. {
  40. l=1;
  41. }
  42. }
  43. if(l) c++;
  44. }
  45. cout<<"Case "<<rr;
  46. if(c==n) cout<<": Yes"<<endl;
  47. else cout<<": No"<<endl;
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment