Thursday, July 30, 2015

1338 - Hidden Secret!

#include<bits/stdc++.h>
using namespace std;
 
int main()
{
    int T,l1,l2,i,j,c=1;
    char str1[105],str2[105];
//    freopen("check.txt","r",stdin);
    scanf("%d",&T);
    getchar();
 
    while(T--)
    {
        gets(str1);
        gets(str2);
 
        int counter=0,check[26]= {0};
        bool flag = false;
        l1 = strlen(str1);
        l2 = strlen(str2);
 
        for(i=0; i<l1; i++)
        {
            if(str1[i]==' ')
                continue;
            str1[i]=toupper(str1[i]);
            check[str1[i]-'A']++;
            counter++;
        }
 
 
        for(j=0; j<l2; j++)
        {
            if(str2[j]==' ')
                continue;
 
            str2[j]=toupper(str2[j]);
            counter--;
        }
        if(counter != 0)
        {
            printf("Case %d: No\n",c++);
            continue;
        }
        for(i=0; i<l2; i++)
        {
            if(str2[i]==' ')
                continue;
            check[str2[i]-'A']--;
        }
        for(i=0; i<26; i++)
        {
            if(check[i]!=0)
            {
                flag = true;
                break;
            }
        }
        if(flag)
            printf("Case %d: No\n",c++);
        else
            printf("Case %d: Yes\n",c++);
 
    }
    return 0;
}

No comments:

Post a Comment

Triathlon

Triathlon - CodeChef # include < bits/stdc++.h > using namespace std ; # define fi first # define se second # define mp ...