| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 149099 | ----MIT합격선---- (#200) | HicCup (FXCUP4_hiccup) | C++17 | 23 ms | 3328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <utility>
#include <stack>
using namespace std;
typedef pair<char, int> pci;
bool check(const string& S, int x){
stack<char> T;
int n = S.size();
for(int i=0; i<n; i++){
if(S[i]=='H') T.push('(');
else{
if(T.empty()) return false;
if(T.top()=='(') T.pop();
}
}
return T.empty();
/*
stack<pci> T;
bool series = false;
for(int i=0, st=0; i<n; i++){
if(S[i]=='H'){
st = 1;
}
if(S[i]=='C'){
st = 2;
}
if(S[i]=='!'){
if(st>0 && st!=2) return false;
st = (st>0 ? -1 : st-1);
}
T.push({S[i], st});
if(st<=-x){
for(int j=0; j<x+2; j++) T.pop();
st = (T.empty() ? 0 : T.top().second);
nonempty = true;
}
}
*/
return false;
}
int HicCup(std::string S) {
int n = S.size();
int s = 0, e = 1000000;
return check(S, 0) ? 0 : -1;
while(s<e){
int mid = (s+e+1)/2;
if(check(S, mid)) s = mid;
else e = mid-1;
}
return check(S, s) ? s : -1;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
