Problem
Chef has a certain liking towards certain English characters. He considers these characters beautiful. You are given a string consisting of all the characters Chef finds beautiful.
Chef considers a word if each and every character present in the word is beautiful. Given a list of words, determine which of them are .
Input Format
- The first line of the input contains a string , consisting of beautiful characters. Each character in will appear only once.
- The second line of the input contains an integer .
- Each of the following lines contains a single string , denoting the word in the list.
Output Format
For each of the words, output "Yes" (without quotes) if the word is divine and "No" (without quotes) otherwise.
Constraints
- Each character in will appear only once.
- , consist only of lowercase English alphabets.
Subtasks
- Subtask (30 points): =
- Subtask (70 points) : Original constraints
Sample 1:
rested 3 terp dest nop
No Yes No
Explanation:
Test Case : Character isn't beautiful. Therefore this word is not divine.
Test Case : Every character in the word is beautiful. Therefore, this word is divine.
Program :
#include <stdio.h>
#include<string.h>
int main(){
char s[26];
scanf("%s",s);
int t;
scanf("%d\n",&t);
while(t-->0)
{
char a[26];
scanf("%s",a);
int i,j,count=0;
for(i=0;i<strlen(a);i++)
{
for(j=0;j<strlen(s);j++)
{
if(a[i]!=s[j])
{
count==0;
}
else
{
count++;
break;
}
}
}
if(count==strlen(a))
{
printf("Yes\n");
}
else
{
printf("No\n"); }
}
return 0;
}
0 Comments