Submission #149064

# Submission time Handle Problem Language Result Execution time Memory
149064 2019-09-01T05:40:04 Z Cafe Maru(#3599, bryan, pps789, kazel) HicCup (FXCUP4_hiccup) C++17
0 / 100
6 ms 384 KB
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;

int HicCup(std::string S) {
	int N = S.size();
    int ans = 1111111;
    vector<int> es, cs;
    es.push_back(0);
    cs.push_back(0);
    for(int i=N-1;i>=0;i--) {
        if (S[i] == 'H') {
            int e = es.back();
            int c = cs.back();
            es.pop_back();
            cs.pop_back();
            if (es.empty()) return -1;
            if(e > 0 && c == 0) {
                return -1;
            } else if (e == 0 && c == 0) {
                continue;
            } else if (e == 0 & c > 0) {
                ans = 0;
            } else {
                int t = e/c;
                ans = min(ans, t);
            }
        } else if (S[i] == 'C') {
            cs.back()++;
            es.push_back(0);
            cs.push_back(0);
        } else {
            es.back()++;
        }
    }
    if (ans == 1111111) ans = -1;

	return ans;
}

Compilation message

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:22:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
             } else if (e == 0 & c > 0) {
                        ~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -