Submission #149624

# Submission time Handle Problem Language Result Execution time Memory
149624 2019-09-01T06:51:46 Z Showing Hands(#3746, hamzqq9, yusufake) HicCup (FXCUP4_hiccup) C++17
0 / 100
5 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=1000000;

	while(bas<=son) {

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

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

	}

	return son;

}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -