Submission #149690

# Submission time Handle Problem Language Result Execution time Memory
149690 2019-09-01T06:58:19 Z Showing Hands(#3746, hamzqq9, yusufake) HicCup (FXCUP4_hiccup) C++17
100 / 100
88 ms 4352 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,pr2=0;

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

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

			gr.pb(-1);
			pr2=0;

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

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

			gr.back()=k;

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

			pr=1;
			pr2=1;

		}
		else {

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

			if(sz(gr) && gr.back()!=-1) {

				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 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 23 ms 4352 KB Output is correct
6 Correct 14 ms 4272 KB Output is correct
7 Correct 14 ms 4352 KB Output is correct
8 Correct 23 ms 4224 KB Output is correct
9 Correct 22 ms 4352 KB Output is correct
10 Correct 14 ms 4224 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 23 ms 4352 KB Output is correct
6 Correct 14 ms 4272 KB Output is correct
7 Correct 14 ms 4352 KB Output is correct
8 Correct 23 ms 4224 KB Output is correct
9 Correct 22 ms 4352 KB Output is correct
10 Correct 14 ms 4224 KB Output is correct
11 Correct 15 ms 4352 KB Output is correct
12 Correct 17 ms 4324 KB Output is correct
13 Correct 18 ms 4352 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 14 ms 4352 KB Output is correct
16 Correct 6 ms 472 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 7 ms 640 KB Output is correct
19 Correct 35 ms 4224 KB Output is correct
20 Correct 21 ms 4352 KB Output is correct
21 Correct 53 ms 4224 KB Output is correct
22 Correct 47 ms 4096 KB Output is correct
23 Correct 88 ms 4216 KB Output is correct
24 Correct 23 ms 4352 KB Output is correct
25 Correct 23 ms 4352 KB Output is correct
26 Correct 21 ms 4352 KB Output is correct
27 Correct 59 ms 4352 KB Output is correct
28 Correct 77 ms 4224 KB Output is correct
29 Correct 81 ms 4224 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 6 ms 384 KB Output is correct
32 Correct 11 ms 512 KB Output is correct
33 Correct 6 ms 384 KB Output is correct