답안 #149612

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149612 2019-09-01T06:50:25 Z Showing Hands(#3746, hamzqq9, yusufake) HicCup (FXCUP4_hiccup) C++17
0 / 100
6 ms 384 KB
#include "hiccup.h"
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 1000000005
#define MOD 1000000007
using namespace std;

int n;
string s;

bool ok(int k) {

	vector<int> gr;
	bool pr=0;

	for(int i=0;i<n;i++) {

		if(s[i]=='H') {

			gr.pb(-1);

		}
		else if(s[i]=='C') {

			if(!sz(gr) || gr.back()!=-1) return 0;

			gr.back()=k;

			pr=1;

		}
		else {

			if(sz(gr) && gr.back()==-1) return 0;
			if(!sz(gr) && !pr) return 0;

			if(sz(gr)) {

				gr.back()--;

				if(gr.back()==0) gr.ppb();

			}

		}

	}

	return sz(gr)==0;

}

int HicCup(std::string s) {

	n=sz(s);

	::s=s;

	int bas=0,son=2000;

	while(bas<=son) {

		int orta=(bas+son)>>1;

		if(!ok(orta)) son=orta-1;
		else bas=orta+1;

	}

	return son;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -