Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- double const EPS=1e-6;
- using namespace std;
- const int N = 35;
- int inp[N][N], n, m, k, ans[N], p;
- void input()
- {
- cin >> n >> m >> k;
- int i, j ;
- for ( i = 0 ; i < n ; i++ )
- {
- for ( j = 0 ; j < k ; j++ ) cin >> inp[i][j];
- }
- cin >> p ;
- for ( i = 0 ; i < p ; i++ ) cin>> ans[i];
- }
- bool solve()
- {
- int i, j, x;
- for ( i = 0 ; i < n ; i++ )
- {
- bool ok = false ;
- for ( j = 0 ; j < k && !ok ; j++ )
- {
- int wish = inp[i][j];
- // printf ( " Person :: %d wish :: %d\n", i , wish );
- bool nai = true ;
- bool ase = false;
- for ( x = 0 ; x < p ; x++ )
- {
- if ( abs(wish) == ans[x] )
- {
- nai = false;
- ase = true;
- }
- }
- if ( wish < 0 && nai ) ok = true;
- if ( wish > 0 && ase ) ok = true;
- }
- if ( ok == false ) return 0;
- }
- return 1;
- }
- int main()
- {
- int cs, t;
- scanf("%d",&t);
- for ( cs = 1 ;cs <= t ; cs++ )
- { input();
- printf("Case %d: %s\n",cs,solve()?"Yes":"No");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement