Spoj - ACODE , Could anyone tell me what is wrong in my code ? Have I missunderstood something?


#1

#include <bits/stdc++.h>

using namespace std;

int main(){
int poc=0;
string s;
while(s!=“0”){
vector jed;
getline(cin>>ws,s);
if (s==“0”) break;
s=“00”+s;
int n=s.length();
jed.insert(jed.begin(),n+3,0);
jed[1]=1;
for (int i=2;i<n;i++){
if (s[i]==‘0’ && (s[i-1]>‘2’ || s[i-1]==‘0’) ){
jed[n-1]=0;
break;
}
if ( ( s[i-1] > ‘2’ || s[i-1] == ‘2’ && s[i] > ‘6’ ) || s[i+1] == ‘0’ || s[i]==‘0’ || s[i-1]==‘0’) jed[i]+=jed[i-1];
else jed[i]+=jed[i-1]+jed[i-2];
}
cout<<jed[n-1];
jed.clear();
}

return 0;

}