#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;
string s;
bool valid(int start,int fin)
{
if(start>=fin)
return true;
if((fin-start)%2)
return false;
if(s[start]!='H')
return false;
int tmp=0,ind;
for(ind=start;tmp!=0&&ind<=fin;ind++)
{
if(s[ind]=='H')
tmp++;
else if(s[ind]=='C')
tmp--;
else
return false;
}
if(tmp!=0)
return false;
return valid(start+1,ind-2)&&valid(ind,fin);
}
int HicCup(string S) {
int N = S.size();
s=S;
if(valid(0,N-1))
return 0;
return -1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |