Submission #150864

#TimeUsernameProblemLanguageResultExecution timeMemory
150864Welcome to osu! (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
6 ms384 KiB
#include "hiccup.h" #include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long ll; typedef pair<int, int> pii; int HicCup(std::string S) { int N = S.size(); int lo=0, hi=N; stack<pii> st; while (lo<hi) { while (!st.empty()) st.pop(); int mid = lo+hi+1>>1; bool flag = true; for (int i=0; i<N; i++) { if (S[i] == 'H') st.push(pii('H', 0)); else if (S[i] == 'C') { if (st.top().va != 'H') { flag = false; break; } st.pop(); st.push(pii('C', 1)); } else if (S[i] == '!') { if (st.top().va != 'C') { flag = false; break; } pii tmp = st.top(); st.pop(); st.push(pii('C', tmp.vb+1)); if (tmp.vb+1 == mid) st.pop(); } } if (!st.empty()) flag = false; if (flag) lo = mid; else hi = mid-1; } return lo; }

Compilation message (stderr)

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:17:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = lo+hi+1>>1;
             ~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...