#include "hiccup.h"
#include <iostream>
#include <vector>
int HicCup(std::string S) {
int N = S.size();
int count = 0;
int set = 0;
std::vector<char> arr;
for (int i = 0; i < N; i++) {
if (!arr.empty()) {
if (arr.back() == 'H' && S[i] == 'C') {
arr.pop_back();
i++;
set++;
while (S[i] == '!') {
i++;
count++;
}
i--;
continue;
}
else if (arr.back() == 'H' && S[i] == '!') {
std::cout << "���";
return -1;
}
else if (arr.back() == 'H' && S[i] == 'H') {
arr.push_back('H');
}
}
else {
if (S[i] == 'C') {
std::cout << S[i] << ',' << "here";
return -1;
}
else if (S[i] == 'H') {
arr.push_back('H');
}
}
if (S[i] == '!' && set == 0) {
return -1;
}
if (S[i] == '!') {
count++;
}
}
return count / set;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |