#include "hiccup.h"
#include <stack>
std::stack<char> st;
int HicCup(std::string S) {
int N = S.size();
int res = 0;
for (int i=0; i<N; i++) {
if (S[i] == 'H') {
st.push(S[i]);
} else if (S[i] == 'C') {
if (st.top() == 'H') {
st.pop();
} else {
res = -1;
break;
}
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Runtime error |
5 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |