Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a,b,c,d,e,f,m,n,l,p,pos[100][100]={0},t,i,j,k;
- cin>>t;
- for(l=1;l<=t;l++)
- {
- int pos[100][100]={0},neg[100][100]={0},flag=0,take[100]={0};
- bool happy[100]={false};
- cin>>n>>m>>k;
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=k;j++)
- {
- cin>>a;
- if(a>0)
- pos[i][a]=1;
- else
- neg[i][(-1*a)]=1;
- }
- }
- cin>>p;
- for(i=1;i<=p;i++)
- {
- cin>>a;
- take[a]=1;
- }
- for(i=1;i<=m;i++)
- {
- for(j=1;j<=n;j++)
- {
- if(take[i]==1)
- {
- if(pos[j][i]==1)
- happy[j]=true;
- }
- else if(take[i]==0)
- {
- if(neg[j][i]==1)
- happy[j]=true;
- }
- }
- }
- for(i=1;i<=n;i++)
- {
- if(happy[i]==false)
- {
- flag=1;
- break;
- }
- }
- if(flag==0)
- cout<<"Case "<<l<<": "<<"Yes"<<endl;
- else
- cout<<"Case "<<l<<": "<<"No"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement