# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613087 | ajpiano | HicCup (FXCUP4_hiccup) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "hiccup.h"
using namespace std;
int HicCup(std::string S) {
int N = S.size();
int hbef = 0;
for(int i = 0; i < N; i++){
if(S[i] == '!') continue;
if(S[i] == 'H') hbef++;
else{
hbef--;
if(hbef < 0) return -1;
}
}
if(hbef != 0) return -1;
return 0;
}
int main(){
string s; cin >> s;
cout << HicCup(s) << "\n";
}