# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
613087 | 2022-07-30T03:19:56 Z | ajpiano | HicCup (FXCUP4_hiccup) | C++17 | 0 ms | 0 KB |
#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"; }