#include "hiccup.h"
#include <iostream>
using namespace std;
int HicCup(std::string S) {
int N = S.size();
int h = (S[0]=='H' ? 1 : 0);
int c = 0;
int x = 0;
char ex = S[0];
if (S[0] != 'H') return -1;
for(int i=1;i<N;i++){
if(S[i] == 'H') h++;
if(S[i] == '!') x++;
if(S[i] == 'C') c++;
switch(ex) {
case 'H':
if(S[i]=='!') {
//cout << "H->!" << endl;
return -1;
}
break;
case 'C':
/*
if(S[i]=='C') {
cout << "C->C" << endl;
return -1;
}*/
break;
case '!':
break;
default:
return -1;
break;
}
ex = S[i];
}
if(h!=c) return -1;
return (x/h);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
19 ms |
3328 KB |
Output is correct |
6 |
Correct |
12 ms |
3328 KB |
Output is correct |
7 |
Correct |
13 ms |
3328 KB |
Output is correct |
8 |
Correct |
21 ms |
3328 KB |
Output is correct |
9 |
Correct |
19 ms |
3328 KB |
Output is correct |
10 |
Incorrect |
20 ms |
3328 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
512 KB |
Output is correct |
5 |
Correct |
19 ms |
3328 KB |
Output is correct |
6 |
Correct |
12 ms |
3328 KB |
Output is correct |
7 |
Correct |
13 ms |
3328 KB |
Output is correct |
8 |
Correct |
21 ms |
3328 KB |
Output is correct |
9 |
Correct |
19 ms |
3328 KB |
Output is correct |
10 |
Incorrect |
20 ms |
3328 KB |
Output isn't correct |