제출 #618040

#제출 시각아이디문제언어결과실행 시간메모리
618040czhang2718HicCup (FXCUP4_hiccup)C++17
컴파일 에러
0 ms0 KiB
// #include "hiccup.h"
using namespace std;
#include "bits/stdc++.h"

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.size() && 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);
	}
	assert(ans!=1e9);
	return ans;
}
 
int main(){
	string s;
	cin >> s;
	cout << HicCup(s);
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccGQ1HlR.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccUPqGfU.o:hiccup.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status