Problem
Ram and Shyam are playing a game of Truth and Dare. In this game, Shyam will ask Ram to perform tasks of two types:
- Truth task: Ram has to truthfully answer a question.
- Dare task: Ram has to perform a given task.
Each task is described by an integer. (If a truth task and a dare task are described by the same integer, they are still different tasks.) You are given four lists of tasks:
- : the truth tasks Ram can perform.
- : the dare tasks Ram can perform.
- : the truth tasks Shyam can ask Ram to perform.
- : the dare tasks Shyam can ask Ram to perform.
Note that the elements of these lists are not necessarily distinct, each task may be repeated any number of times in each list.
Shyam wins the game if he can find a task Ram cannot perform. Ram wins if he performs all tasks Shyam asks him to. Find the winner of the game.
Let's take an example where Ram can perform truth tasks , and and dare tasks and , and Shyam can give him truth tasks and and a dare task . We can see that whichever truth or dare tasks Shyam asks Ram to perform, Ram can easily perform them, so he wins. However, if Shyam can give him dare tasks and , then Ram will not be able to perform dare task , so Shyam wins.
Input
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains a single integer .
- The second line contains space-separated integers .
- The third line contains a single integer .
- The fourth line contains space-separated integers .
- The fifth line contains a single integer .
- The sixth line contains space-separated integers .
- The seventh line contains a single integer .
- The eighth line contains space-separated integers .
Output
For each test case, print a single line containing the string "yes"
if Ram wins the game or "no"
otherwise.
Constraints
- for each valid
- for each valid
- for each valid
- for each valid
Sample 1:
4 2 1 2 3 1 3 2 1 2 2 3 2 2 1 2 3 1 3 2 1 2 3 3 2 4 3 3 2 5 2 2 100 1 2 1 100 2 1 2 3 1 3 2 1 2 3 3 2 2
yes no yes yes
Explanation:
Example case 1: Ram's truth tasks are and his dare tasks are . Shyam's truth tasks are and his dare tasks are . Ram can perform all tasks Shyam gives him.
Example case 2: Ram's truth tasks are and his dare tasks are . Shyam's truth tasks are and his dare tasks are . If Shyam asks Ram to perform dare task , Ram will not be able to do it.
Program :
#include <stdio.h>
int main(void)
{
int t,p,r,s,q;
int f1=0;
int f2=0;
int a[100],b[100],c[100],d[100];
scanf("%i",&t);
while(t--)
{
scanf("%i",&p);
for(int i=0;i<p;i++)
{
scanf("%i",&a[i]);
}
scanf("%i",&r);
for(int i=0;i<r;i++)
{
scanf("%i",&b[i]);
}
scanf("%i",&s);
for(int i=0;i<s;i++)
{
scanf("%i",&c[i]);
}
scanf("%i",&q);
for(int i=0;i<q;i++)
{
scanf("%i",&d[i]);
}
for(int i=0;i<s;i++)
{
for(int j=0;j<p;j++)
{
if(c[i]==a[j])
{
f1++;
break;
}
}
}
for(int i=0;i<q;i++)
{
for(int j=0;j<r;j++)
{
if(d[i]==b[j])
{
f2++;
break;
}
}
}
if(f1==s && f2==q)
printf("yes\n");
else
printf("no\n");
f1=0;
f2=0;
}
return 0;
}
0 Comments