Thursday, March 21, 2019

FRGTNLNG : Forgotten Language

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;

}

No comments:

Post a Comment

CHEFST: Chef and the stones

CHEFST: Chef and the stones Link for the problem:  CHEFST SOLUTION: For a given max possible no of stones that can be removed from ea...