Submission #150410

# Submission time Handle Problem Language Result Execution time Memory
150410 2019-09-01T08:21:16 Z Torat(#3726, Osama_Alkhodairy, mohammedehab2002, mahmoudbadawy) HicCup (FXCUP4_hiccup) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
//~ #include "hiccup.h"
#include "grader.cpp"
using namespace std;

const int N = 1000001;

int n;
string s;
vector <int> h;

bool valid(){
    int o = 0;
    for(auto &i : s){
        o += i == 'H';
        o -= i == 'C';
        if(o < 0) return 0;
    }
    if(o) return 0;
    for(auto &i : s){
        if(i == 'H') o = 0;
        else if(i == 'C') o = 1;
        else if(o == 0) return 0;
    }
    return 1;
}
int HicCup(std::string S) {
    s = S;
    n = s.size();
    if(!valid() || s == string(n, '!')) return -1;
    h.resize(n);
    h[0] = 1;
    for(int i = 1 ; i < n ; i++){
        h[i] = h[i - 1];
        if(s[i] == 'H') h[i]++;
        else if(s[i] == 'C') h[i]--;
        //~ else v[h[i]].push_back(i);
    }
    vector <int> exs(n), cs(n);
    int ans = n;
    for(int i = n - 1 ; i >= 0 ; i--){
        if(s[i] == '!') exs[h[i]]++;
        else if(s[i] == 'C'){
            cs[h[i]]++;
            ans = min(ans, exs[h[i]] / cs[h[i]]);
        }
    }
    return ans;
}

Compilation message

/tmp/ccSX0UT9.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccO0pLA8.o:hiccup.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status