WA in ALETHIO (june cookoff)

I have taken of all border cases like:

  1. string of all zeroes
  2. no starting redundant zeroes in output
  3. giving correct ans for all the test cases I could think of

Here’s my code:

#include<string>
#include<iostream>
#include<cstdio>
using namespace std;

bool isbigger(string a,string b,int j) // returns true if auxillary number > max
{
int asz=j+1,bsz=b.size(),diff=bsz-asz; //asz is size of a, sim bsz
if(diff>0) while(diff--) a='0'+a;//padding0
else if(diff<0){
    diff=-diff;
    while(diff--) b='0'+b; //padding 0
    }
if(a>b) return 1;
else return 0;
}


main(){

string a;
cin>>a;
int i,j,k,chars=0;
string aux="",max="0";

for(i=0;a[i]=='0';i++);
for(;a[i];i++){
   aux="";
   for(j=0;a[i+j]=='0';j++);
   for(;a[i+j];j++){
                        if(a[i+j]>='A' && a[i+j]<='Z'){
                        chars++;
                        if(chars>1) break;
                        aux+='9';}
                        else aux+=a[i+j];
                        if(isbigger(aux,max,j)) max=aux;
   }
   chars=0;
   }

   if(max=="") max="0";
   cout<<max;
   }//end of code

try this case

A000B99

…this gives 999 as the ans but it should be 9000…hope this helps u find the bug…:slight_smile:

see this link…see the output line numbers 4,5,6…see the mistake!!!

http://www.codechef.com/viewsolution/2310576

my program is running fine…but still i m getng WA…unable to figure out y…

@nanditagiri92…this is your corrected code…LINK!!!

the error was…on line 25 of your code…you were printing…“in this”!!!

remove that and u will be through…hope this helps…:slight_smile:

thanks :slight_smile:

1 Like