TOTR:WRONG ANSWER

THE CODE RUNS FINE FOR TEST CASES…

#include <iostream>
#include <cstdlib>
#include<cctype>
#include<cstring>
using namespace std;
int main ()
{
	int t;
	char m[26];
	char strabc[]="abcdefghijklmnopqrstuvwxyz";
	char strABC[]="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	scanf("%d%s",&t,m);
	while(t--)
	{
		char a[100];
		scanf("%s",a);
		//cout<<"a= "<<a<<endl;
		for(int i=0;i<strlen(a);i++)
		{
			if(a[i]>=65 &&a[i]<=90)
			{
				for(int j=0;j<26;j++)
				{
					if(strABC[j]==a[i])
					{	printf("%c",m[j]-96+64);
						//cout<<endl<<"m[j]= "<<m[j]<<endl;
						//cout<<"j="<<j<<endl;
						//cout<<"strABC[j]="<<strABC[j]<<endl;
					}
				}
			}
			else if(isalpha(a[i]))
			{
				for(int j=0;j<26;j++)
				{
					if(strabc[j]==a[i])
						printf("%c",m[j]);
				}
			}
			else if(a[i]=='_')
					printf(" ");
			else
				printf("%c",a[i]);
		}		
		printf("\n");
}
  return 0;
}

bro, instead checking a[i] twice, i suggest, after learning whether a[i] is capital or not, just call representative of that char from corresponding index of m.(IMHO)

At last used different approach to solve… AC… 0.00 sec… good…

Solution

#include
however, verdict WA still

bro, why you check twice whether if a[i] is lowercase or uppercase. and also, imho, m is always lowercase.

also, i suggest ideone, that compiler sometimes hints bugs in your code

1 Like

if you STILL having problems, have a glance: http://www.codechef.com/viewsolution/3276523

i modified my code still… WA…
http://www.codechef.com/viewsolution/3276884

sometimes it doesn’t

1 Like