답안 #618039

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618039 2022-08-01T19:58:55 Z czhang2718 HicCup (FXCUP4_hiccup) C++17
24 / 100
38 ms 29804 KB
// #include "hiccup.h"
using namespace std;
#include "bits/stdc++.h"
 
const int N=1e6+1;
vector<int> adj[N];
int cnt[N];
int X, nodes, ans;
bool bad;

bool check(string s){
	int ps=0;
	for(char c:s){
		if(c=='H') ps++;
		else ps--;
		if(ps<0) return 0;
	}
	return ps==0;
}

int HicCup(std::string S) {
	string t="";
	for(char c:S) if(c!='!') t+=c;
	if(!check(t)) return -1;
	t="";
	for(char c:S) if(c!='H') t+=c;
	int exc=0, c=0;
	if(t[0]=='!') return -1;
	int ans=1e9;
	for(int i=t.size()-1; i>=0; i--){
		(t[i]=='!'?exc:c)++;
		if(t[i]=='C') ans=min(ans, exc/c);
	}
	return ans;
}
 
// int main(){
// 	string s;
// 	cin >> s;
// 	cout << HicCup(s);
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23804 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 13 ms 23940 KB Output is correct
5 Correct 37 ms 29728 KB Output is correct
6 Correct 25 ms 29768 KB Output is correct
7 Correct 24 ms 29760 KB Output is correct
8 Correct 38 ms 29804 KB Output is correct
9 Correct 38 ms 29796 KB Output is correct
10 Correct 25 ms 29732 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23804 KB Output is correct
3 Correct 12 ms 23764 KB Output is correct
4 Correct 13 ms 23940 KB Output is correct
5 Correct 37 ms 29728 KB Output is correct
6 Correct 25 ms 29768 KB Output is correct
7 Correct 24 ms 29760 KB Output is correct
8 Correct 38 ms 29804 KB Output is correct
9 Correct 38 ms 29796 KB Output is correct
10 Correct 25 ms 29732 KB Output is correct
11 Correct 13 ms 23764 KB Output is correct
12 Correct 25 ms 29316 KB Output is correct
13 Correct 21 ms 28112 KB Output is correct
14 Correct 18 ms 27620 KB Output is correct
15 Correct 12 ms 23784 KB Output is correct
16 Incorrect 27 ms 29688 KB Output isn't correct
17 Halted 0 ms 0 KB -