Submission #150336

# Submission time Handle Problem Language Result Execution time Memory
150336 2019-09-01T08:10:24 Z usa1+samsung2(#3703, adman, nona1314, wowoto9772) HicCup (FXCUP4_hiccup) C++17
24 / 100
26 ms 3328 KB
#include "hiccup.h"
#include <iostream>

using namespace std;

int HicCup(std::string S) {
	int N = S.size();
        int h = 0;
        int x = 0;
        if (N==0) return 0;
        if (S[0] != 'H') return -1;

        {
            int cur = 0;
            char ex = S[0];
            for(int i = 1 ; i < N;i++) {
                const char &s = S[i];
                if((s != 'H') && (s!='C') && (s!='!')){
                    return -1;
                }
                switch(ex) {
                    case 'H':
                        if(s=='H') cur++;
                        else if(s=='!') return -1;
                        break;
                    case 'C':
                        if(s=='C') cur--;
                        break;
                    case '!':
                        /*
                        if(s=='H') cur++;
                        else if(s=='C') cur--;
                        */
                        break;
                    default:
                        return -1;
                        break;
                }
                //cout << cur << endl;
                if(cur<0) return -1;
                if(s!='!')ex = s;
            }
            if(ex=='H' || cur != 0) return -1;
        }

        for(int i=0;i<N;i++){
            if(S[i] == 'H') h++;
            if(S[i] == '!') x++;
        }
        return (x/h);
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 26 ms 3328 KB Output is correct
6 Correct 13 ms 3200 KB Output is correct
7 Correct 14 ms 3200 KB Output is correct
8 Correct 26 ms 3328 KB Output is correct
9 Correct 26 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 26 ms 3328 KB Output is correct
6 Correct 13 ms 3200 KB Output is correct
7 Correct 14 ms 3200 KB Output is correct
8 Correct 26 ms 3328 KB Output is correct
9 Correct 26 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 14 ms 3328 KB Output is correct
12 Correct 13 ms 3328 KB Output is correct
13 Correct 13 ms 3328 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 13 ms 3328 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Incorrect 16 ms 3200 KB Output isn't correct
20 Halted 0 ms 0 KB -