# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
149555 | | 팀명못정해서15시간째고민중인팀 (#200) | HicCup (FXCUP4_hiccup) | C++17 | | 344 ms | 7504 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;
int HicCup(std::string S) {
int N = S.size();
stack<int> st;
bool chk=true,r=false;
for(auto i:S){
if(i=='H') st.push(1),r=false;
else if(i=='C'){
if(!st.empty()) st.pop(),r=true;
else chk=false;
}
else if(!r) chk=false;
}
if(!st.empty()) chk=false;
if(!chk) return -1;
else{
int l=0,r=1000000,Max=0;
while(l<=r){
int mid=(l+r)/2;
//printf("%d %d %d\n",l,r,mid);
stack<pair<int,int>> s;
bool ct=true;
for(auto i:S){
//if(!s.empty()) printf("%d %d\n",s.top().first,s.top().second);
//else printf("��\n");
if(!s.empty()&&s.top().first==2&&s.top().second==mid) s.pop();
if(i=='H') s.push({1,0});
else if(i=='C') s.pop(),s.push({2,0});
else{
if(!s.empty()){
int c=s.top().second; s.pop();
s.push({2,c+1});
}
}
}
while(!s.empty()&&s.top().second==mid) s.pop();
if(s.empty()) l=mid+1,Max=max(Max,mid);
else r=mid-1;
}
return Max;
}
}
Compilation message (stderr)
hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:25:18: warning: unused variable 'ct' [-Wunused-variable]
bool ct=true;
^~
hiccup.cpp:6:6: warning: unused variable 'N' [-Wunused-variable]
int N = S.size();
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |