Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int T,i;
- scanf("%d",&T);
- for(i=1;i<=T;i++){
- int a[100][100],n,m,j,k,l,p,q[100],cnt=0,mcn=0,cn=0,x,tnt=0;
- scanf("%d %d %d",&n,&m,&k);
- for(j=0;j<n;j++){
- for(l=0;l<k;l++){
- scanf("%d",&a[j][l]);
- }
- }
- scanf("%d",&p);
- for(j=0;j<p;j++){
- scanf("%d",&q[j]);
- }
- mcn=0;
- printf("Case %d: ",i);
- for(j=0;j<n;j++){
- cn=0;
- for(l=0;l<k;l++){
- cnt=0;
- tnt=0;
- if(a[j][l]<0){
- for(x=0;x<p;x++){
- if(-q[x]==a[j][l])
- tnt++;
- }
- if(tnt==0){
- cn++;
- break;
- }
- }
- else if(a[j][l]>0){
- for(x=0;x<p;x++){
- if(q[x]==a[j][l])
- cnt++;
- }
- if(cnt>0){
- cn++;
- break;
- }
- }
- }
- if(cn>0)
- mcn++;
- }
- if(mcn<n)
- printf("No\n");
- else if(mcn==n)
- printf("Yes\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement