Advertisement
erfanul007

LOJ 1261

Dec 7th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. int T,i;
  6. scanf("%d",&T);
  7. for(i=1;i<=T;i++){
  8. int a[100][100],n,m,j,k,l,p,q[100],cnt=0,mcn=0,cn=0,x,tnt=0;
  9. scanf("%d %d %d",&n,&m,&k);
  10. for(j=0;j<n;j++){
  11. for(l=0;l<k;l++){
  12. scanf("%d",&a[j][l]);
  13. }
  14. }
  15. scanf("%d",&p);
  16. for(j=0;j<p;j++){
  17. scanf("%d",&q[j]);
  18. }
  19. mcn=0;
  20. printf("Case %d: ",i);
  21. for(j=0;j<n;j++){
  22. cn=0;
  23. for(l=0;l<k;l++){
  24. cnt=0;
  25. tnt=0;
  26. if(a[j][l]<0){
  27. for(x=0;x<p;x++){
  28. if(-q[x]==a[j][l])
  29. tnt++;
  30. }
  31. if(tnt==0){
  32. cn++;
  33. break;
  34. }
  35. }
  36. else if(a[j][l]>0){
  37. for(x=0;x<p;x++){
  38. if(q[x]==a[j][l])
  39. cnt++;
  40. }
  41. if(cnt>0){
  42. cn++;
  43. break;
  44. }
  45. }
  46. }
  47. if(cn>0)
  48. mcn++;
  49. }
  50. if(mcn<n)
  51. printf("No\n");
  52. else if(mcn==n)
  53. printf("Yes\n");
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement