Submission #148742

#TimeUsernameProblemLanguageResultExecution timeMemory
148742ummm (#200)HicCup (FXCUP4_hiccup)C++17
100 / 100
125 ms5296 KiB
#include "hiccup.h" #include <iostream> #include <iomanip> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> using namespace std; #define pb push_back #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) typedef long long ll; typedef long double ld; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const int N = 1e5 + 10; bool test(string s, int mid); int HicCup(std::string s) { int n = s.length(); int lo = 0, hi = n; while (lo <= hi) { int mid = (lo + hi) / 2; if (test(s, mid)) { lo = mid + 1; } else { hi = mid - 1; } } return lo - 1; } bool test(string s, int mid) { int n = s.length(); stack<char> stk; stk.push('#'); bool del = false; for (int i = n - 1; i >= 0; --i) { if (s[i] == 'H') { while (del and stk.top() == '!') { stk.pop(); } del = true; if (stk.top() != 'C') { return false; } stk.pop(); for (int j = 0; j < mid; ++j) { if (stk.top() != '!') { return false; } stk.pop(); } } else { stk.push(s[i]); del = false; } } while (del and stk.top() == '!') { stk.pop(); } return stk.top() == '#'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...