Advertisement
Farjana_akter

Untitled

Feb 19th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int a,b,c,d,e,f,m,n,l,p,pos[100][100]={0},t,i,j,k;
  8. cin>>t;
  9. for(l=1;l<=t;l++)
  10. {
  11. int pos[100][100]={0},neg[100][100]={0},flag=0,take[100]={0};
  12. bool happy[100]={false};
  13. cin>>n>>m>>k;
  14. for(i=1;i<=n;i++)
  15. {
  16. for(j=1;j<=k;j++)
  17. {
  18. cin>>a;
  19. if(a>0)
  20. pos[i][a]=1;
  21. else
  22. neg[i][(-1*a)]=1;
  23. }
  24. }
  25. cin>>p;
  26. for(i=1;i<=p;i++)
  27. {
  28. cin>>a;
  29. take[a]=1;
  30. }
  31. for(i=1;i<=m;i++)
  32. {
  33. for(j=1;j<=n;j++)
  34. {
  35. if(take[i]==1)
  36. {
  37. if(pos[j][i]==1)
  38. happy[j]=true;
  39. }
  40. else if(take[i]==0)
  41. {
  42. if(neg[j][i]==1)
  43. happy[j]=true;
  44. }
  45. }
  46. }
  47. for(i=1;i<=n;i++)
  48. {
  49. if(happy[i]==false)
  50. {
  51. flag=1;
  52. break;
  53. }
  54. }
  55. if(flag==0)
  56. cout<<"Case "<<l<<": "<<"Yes"<<endl;
  57. else
  58. cout<<"Case "<<l<<": "<<"No"<<endl;
  59. }
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement