jeudi 20 juin 2019

I Have passed all the test cases for the problem and even all the test cases on Udebugg and still getting a WA verdict on UVA online judge

Judge Name- UVA Online Judge
Problem Name-Burger Time?
Problem ID-11661
Link-https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2708

I Already Tried To solve It and passed all the test cases provided in the problem pdf as well as on uDebug.Still when i submit the solution, i get a Wrong Answer Verdict.Please Help me with where i am going wrong.Thanks In Advance.

      #include<iostream>
   using namespace std;
   int main(){
   long n;
  while(1){
    cin>>n;
   if(n==0) exit(0);
  char ch;
   long countr=0;
     cin>>ch;
    char start=ch;
long ans=1000000000;
for(long i=1;i<n;i++){
    cin>>ch;
    countr++;
    if(ch=='Z'){
        ans=0;
    }
    else if(start=='R'&&ch=='D')
    {
        if(countr<ans){
            ans=countr;
        }
    }
    else if(start=='D'&&ch=='R'){
        if(countr<ans){
            ans=countr;
        }
    }
    if(ch=='R'){
        start=ch;
        countr=0;
    }
    if(ch=='D'){
        start=ch;
        countr=0;
    }

}
cout<<ans<<endl;

}
 cout<<endl;
 return 0;

 }

Aucun commentaire:

Enregistrer un commentaire