Submission #150122

# Submission time Handle Problem Language Result Execution time Memory
150122 2019-09-01T07:45:39 Z distutpia(#3780, cblimmm, wooks1998) HicCup (FXCUP4_hiccup) C++17
100 / 100
34 ms 11180 KB
#include "hiccup.h"

using namespace std;

int A[1000000];
int B[1000000];

void init(){
	for (int i=0; i<1000000; i++){
		A[i]=0;
		B[i]=0;
	}
}

bool valid(string S){
	int N = S.size();
	bool preH = true;
	int t1=0, t2=0;
	for(int i=0;i<N;i++){
		if (S[i]=='H'){
			t1++;
			preH = true;
		}
		else if (S[i]== 'C'){
			t2++;
			preH = false;
		}
		else if (S[i]== '!'){
			if (preH) return false;
		}
		else{
			return false;
		}
		if (t1<t2){
			return false;
		}
	}
	if (t1!=t2){
		return false;
	}
	return true;
}

int HicCup(std::string S) {
	int N = S.size();
	int min = 10000000;
	if (!valid(S)){
		return -1;
	}
	init();
	int t1=0, t2=0,t3=0;
	for(int i=N-1; i>=0; i--){
		if (S[i]=='H'){
			A[t2-t1] = 0;
			B[t2-t1] = 0;
			t1++;
		}
		else if (S[i]=='C'){
			B[t2-t1]++;
			if (min > A[t2-t1]/B[t2-t1]){
				min = A[t2-t1]/B[t2-t1];
			}
			t2++;
		}
		else if (S[i]=='!'){
			A[t2-t1]++;
		}
	}
	return min;
}

Compilation message

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:51:17: warning: unused variable 't3' [-Wunused-variable]
  int t1=0, t2=0,t3=0;
                 ^~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 10 ms 8320 KB Output is correct
5 Correct 32 ms 11180 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 13 ms 4352 KB Output is correct
8 Correct 31 ms 11180 KB Output is correct
9 Correct 32 ms 11180 KB Output is correct
10 Correct 15 ms 4352 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8192 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 10 ms 8320 KB Output is correct
5 Correct 32 ms 11180 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 13 ms 4352 KB Output is correct
8 Correct 31 ms 11180 KB Output is correct
9 Correct 32 ms 11180 KB Output is correct
10 Correct 15 ms 4352 KB Output is correct
11 Correct 15 ms 4352 KB Output is correct
12 Correct 16 ms 4224 KB Output is correct
13 Correct 14 ms 4352 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 16 ms 4224 KB Output is correct
16 Correct 5 ms 256 KB Output is correct
17 Correct 5 ms 256 KB Output is correct
18 Correct 7 ms 640 KB Output is correct
19 Correct 22 ms 11180 KB Output is correct
20 Correct 24 ms 11180 KB Output is correct
21 Correct 23 ms 11180 KB Output is correct
22 Correct 22 ms 10976 KB Output is correct
23 Correct 24 ms 11180 KB Output is correct
24 Correct 24 ms 11180 KB Output is correct
25 Correct 34 ms 11052 KB Output is correct
26 Correct 25 ms 11140 KB Output is correct
27 Correct 23 ms 11180 KB Output is correct
28 Correct 23 ms 11080 KB Output is correct
29 Correct 22 ms 11180 KB Output is correct
30 Correct 11 ms 8192 KB Output is correct
31 Correct 10 ms 8192 KB Output is correct
32 Correct 12 ms 8448 KB Output is correct
33 Correct 6 ms 384 KB Output is correct