FRGTNLNG : Forgotten Language
Link for Problem: FRGTNLNG
Solution:
In the problem you just have to apply a simple brute force approach.
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k,i,j;
scanf("%d %d",&n,&k);
string a[n];
int b[n]={0};
for(i=0;i<n;i++)
cin>>a[i];
vector <string> v;
for(i=0;i<k;i++)
{
int l;
scanf("%d",&l);
for(j=1;j<=l;j++)
{
string s;
cin>>s;
v.push_back(s);
}
}
int l=v.size();
for(i=0;i<n;i++)
{
for(j=0;j<l;j++)
{
if(a[i]==v[j])
{
b[i]=1;
break;
}
}
}
for(i=0;i<n;i++)
{
if(b[i]==1)
printf("YES ");
else
printf("NO ");
}
printf("\n");
}
return 0;
}
Link for Problem: FRGTNLNG
Solution:
In the problem you just have to apply a simple brute force approach.
Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,k,i,j;
scanf("%d %d",&n,&k);
string a[n];
int b[n]={0};
for(i=0;i<n;i++)
cin>>a[i];
vector <string> v;
for(i=0;i<k;i++)
{
int l;
scanf("%d",&l);
for(j=1;j<=l;j++)
{
string s;
cin>>s;
v.push_back(s);
}
}
int l=v.size();
for(i=0;i<n;i++)
{
for(j=0;j<l;j++)
{
if(a[i]==v[j])
{
b[i]=1;
break;
}
}
}
for(i=0;i<n;i++)
{
if(b[i]==1)
printf("YES ");
else
printf("NO ");
}
printf("\n");
}
return 0;
}
No comments:
Post a Comment