#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==0)
return false;
if(s[start]!='H')
return false;
int tmp=1,ind;
for(ind=start+1;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 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
15 ms |
512 KB |
Output is correct |
5 |
Execution timed out |
1039 ms |
4352 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
15 ms |
512 KB |
Output is correct |
5 |
Execution timed out |
1039 ms |
4352 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |