BEAUTIFUL STRINGS WA help:)

WICQ8 Problem - CodeChef question link and here is my code

#include<iostream>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include <string>   
#include <algorithm>
using namespace std;
int t,len,i,parentalpha[26],alphavalue,tp=26;
long long ans=0;
string A,B;

int main()
{

scanf("%d\n",&t);
while(t--)
{
    for(i=0;i<26;i++)
{
parentalpha[i]=0;
 }
    std::string str;
    std::getline(cin, str);
    std::transform(str.begin(), str.end(), str.begin(), ::tolower);
    cout<<str<<"\n";
   len=str.length();
   for(i=0;i<len;i++)
  {
   if(int(str[i])>=97&&int(str[i])<=122)   
 {
alphavalue=(str[i])-97;
parentalpha[alphavalue]+=1;
}
}
for(i=0;i<26;i++)
{
 printf("%d ",parentalpha[i]);
 }
     cout<<"\n";
     std::sort(parentalpha, parentalpha + 26);
     for(i=0;i<26;i++)
{
printf("%d ",parentalpha[i]);
}
   cout<<"\n";
   for(i=25;i>=0;i--)
{
 ans=ans+(long long)(parentalpha[i]*tp);
 tp--;
}
  printf("%lld\n",ans);
}

return 0;
  }

dont know what i am doing wrong see the second test case :—
Good luck in the Facebook Hacker Cup this year!
my program gives values of e=4 but it should be 3 moreover the output for 2nd case onward are -ve could u help guys!!!
EDIT::: my updated code with the the mistakes i was doing removed but still i get WA here CodeChef: Practical coding for everyone CODE with test cases ::::: bvBK5U - Online C++ Compiler & Debugging Tool - Ideone.com
Still WA :frowning: think cases or test file is broken

I don’t know what they have done with the official tests here. Its in the Peer section, so you can expect flaws as it is not set and tested by the official Codechef team of setters and testers.

My solution to Facebook Hacker Cup 2013 Qualification Round: Beautiful Strings · GitHub Here was my solution which gives WA here. (after removing the Case # stuff)

Go to this link Redirecting... and then go the problem Beautiful Strings, then download the sample input file and run your program with that input and see what output it produces.

ok now i corrected my code an it was illy mistake in while loop where i did not initialize t=26 and ans=0
after that i took input file from net and run them over my code and check it with the outputs of some of the available codes over the web and they all matched still i am getting WA here :frowning:

Its a very easy question but I don’t know why I am getting WA all the time, I am pretty sure that the testfile is broken. Here is a list of my submissions CodeChef: Practical coding for everyone

i think ur answer does not satisfies the test cases also except the 1st one that is what happens to my code also :frowning: ie test cases with spaces are the one giving wrong ans

what? you can check my code. its giving right answer for the test cases mentioned there.

its giving WA for 2nd case onward 27NDLx - Online C++ Compiler & Debugging Tool - Ideone.com where as here is my code giving right answer still rejected here bvBK5U - Online C++ Compiler & Debugging Tool - Ideone.com

same with me its easy still i am getting WA here at 0.01 sec:(

It was not giving negative answers locally on my machine. However, I have fixed the issue. http://ideone.com/HTkPoQ

Something wrong with the test file, confirmed. http://ideone.com/Kyv42W