답안 #764242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764242 2023-06-23T09:25:39 Z idkhandle HicCup (FXCUP4_hiccup) C++17
100 / 100
74 ms 8296 KB
#include "hiccup.h"
#include<vector>
#include<deque>
using namespace std;

bool f(string& S, int X){
    deque<int>Q(S.begin(),S.end());
    vector<int>V{-1};
    bool z=0;
    while(!Q.empty()){
        char q=Q.front();
        Q.pop_front();
        if(q=='H'){
            z=0;
            V.emplace_back(0);
        }else if(q=='C'){
            z=0;
            if(V.back()!=0)return false;
            V.back()=1;
            if(X==0){
                V.pop_back();
                z=1;
            }
        }else{
            if(V.back()<1){
                if(!z)return false;
                continue;
            }
            V.back()++;
            if(V.back()==X+1){
                V.pop_back();
                z=1;
            }
        }
    }
    if(V.size()>1)return false;
    return true;
}

int HicCup(std::string S) {
	int N = S.size();
	int l=-1,r=N;
	while(l<r){
        int X=(l+r+1)/2;
        if(f(S,X))l=X;
        else r=X-1;
	}
	return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 216 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 28 ms 7252 KB Output is correct
6 Correct 23 ms 7252 KB Output is correct
7 Correct 22 ms 7252 KB Output is correct
8 Correct 29 ms 7312 KB Output is correct
9 Correct 28 ms 7336 KB Output is correct
10 Correct 22 ms 7252 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 216 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
5 Correct 28 ms 7252 KB Output is correct
6 Correct 23 ms 7252 KB Output is correct
7 Correct 22 ms 7252 KB Output is correct
8 Correct 29 ms 7312 KB Output is correct
9 Correct 28 ms 7336 KB Output is correct
10 Correct 22 ms 7252 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 31 ms 7276 KB Output is correct
13 Correct 24 ms 7208 KB Output is correct
14 Correct 26 ms 7252 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 28 ms 7240 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 40 ms 7332 KB Output is correct
21 Correct 31 ms 7284 KB Output is correct
22 Correct 53 ms 7312 KB Output is correct
23 Correct 56 ms 6940 KB Output is correct
24 Correct 72 ms 7316 KB Output is correct
25 Correct 32 ms 7252 KB Output is correct
26 Correct 28 ms 7252 KB Output is correct
27 Correct 40 ms 8296 KB Output is correct
28 Correct 74 ms 8276 KB Output is correct
29 Correct 69 ms 7984 KB Output is correct
30 Correct 73 ms 8192 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 296 KB Output is correct
33 Correct 5 ms 852 KB Output is correct