Submission #148954

#TimeUsernameProblemLanguageResultExecution timeMemory
148954서울대학교 연구공원 944동 삼성전자서울대연구소 (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
6 ms512 KiB
#include "hiccup.h" #include<algorithm> #include<vector> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; bool check(ll m, std::string S) { vector<ll> L; L.push_back(0); int flag = 1; for(char c : S){ if(c == 'H'){ L.emplace_back(0); flag = true; } if(c == 'C'){ if(L.back() > 0) return false; L.pop_back(); L.back() += m; flag = false; } if(c == '!'){ if(flag) return false; L.back() -= 1; } } if(L.back() > 0) return false; return true; } int HicCup(std::string S) { ll s = 0, e = S.size(), m; while(s <= e){ ll m = (s+e) / 2; if(check(m, S)) s = m+1; else e = m-1; }swap(s, e); return s == S.size()? -1 : s; }

Compilation message (stderr)

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:43:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  return s == S.size()? -1 : s;
         ~~^~~~~~~~~~~
hiccup.cpp:37:26: warning: unused variable 'm' [-Wunused-variable]
  ll s = 0, e = S.size(), m;
                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...