Submission #148470

# Submission time Handle Problem Language Result Execution time Memory
148470 2019-09-01T04:29:54 Z お前はもう死んでいる(#3784, kuroni, nvmdava, tfg) HicCup (FXCUP4_hiccup) C++17
24 / 100
23 ms 7296 KB
#include "hiccup.h"

#include <vector>

int HicCup(std::string S) {
	int n = S.size();
	std::vector<int> freq(n + 1, 0);
	int ans = 0;
	int bal = 0;
	for(auto c : S) {
		if(c == '!') {
			if(freq[ans] == 0) {
				return -1;
			} else {
				freq[ans]--;
				freq[ans+1]++;
				if(freq[ans] == 0) {
					ans++;
				}
			}
		} else if(c == 'H') {
			bal++;
		} else {
			if(bal == 0) {
				return -1;
			}
			bal--;
			ans = 0;
			freq[0]++;
		}
	}
	if(bal != 0) ans = -1;
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 128 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 128 KB Output is correct
4 Correct 6 ms 628 KB Output is correct
5 Correct 22 ms 7168 KB Output is correct
6 Correct 15 ms 7168 KB Output is correct
7 Correct 15 ms 7296 KB Output is correct
8 Correct 23 ms 7040 KB Output is correct
9 Correct 21 ms 7296 KB Output is correct
10 Correct 19 ms 7168 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 128 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 128 KB Output is correct
4 Correct 6 ms 628 KB Output is correct
5 Correct 22 ms 7168 KB Output is correct
6 Correct 15 ms 7168 KB Output is correct
7 Correct 15 ms 7296 KB Output is correct
8 Correct 23 ms 7040 KB Output is correct
9 Correct 21 ms 7296 KB Output is correct
10 Correct 19 ms 7168 KB Output is correct
11 Correct 17 ms 7168 KB Output is correct
12 Correct 18 ms 7168 KB Output is correct
13 Correct 15 ms 7168 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 23 ms 7168 KB Output isn't correct
16 Halted 0 ms 0 KB -