Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

WA in ALETHIO (june cookoff)

$
0
0

http://www.codechef.com/problems/ALETHIO

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

Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>