# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150967 | 2019-09-01T13:15:05 Z | JustInCase | HicCup (FXCUP4_hiccup) | C++17 | 2 ms | 504 KB |
#include <bits/stdc++.h> #ifdef LOCAL #include "grader.cpp" #else #include "hiccup.h" #endif #define hic_cup HicCup bool check_is_x_string(const std::string &s, int32_t x) { std::stack< int32_t > stH; std::stack< std::pair< int32_t, int32_t > > st; for(int32_t i = 0; i < s.size(); i++) { if(s[i] == 'H') { stH.push(i); } else if(s[i] == 'C') { if(stH.empty()) { return false; } if(!st.empty() && st.top().first > stH.top()) { return false; } st.push({stH.top(), x}); stH.pop(); } else { if(!st.empty()) { auto aux = st.top(); st.pop(); aux.second--; if(aux.second != 0) { st.push(aux); } } } } if(!stH.empty()) { return false; } if(x == 0 || st.empty()) { return true; } else { return false; } } int32_t hic_cup(std::string s) { int32_t low = 0, high = s.size(); while(low <= high) { int32_t mid = (low + high) / 2; if(check_is_x_string(s, mid)) { low = mid + 1; } else { high = mid - 1; } } return low - 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 504 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 252 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 504 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |