# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148924 | 2019-09-01T05:23:52 Z | Dopatii(#3751, bogdan10bos, Gioto, Bodo171) | HicCup (FXCUP4_hiccup) | C++17 | 25 ms | 3328 KB |
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; int HicCup(std::string S) { int N = S.size(); int nrH = 0, nrC = 0; for(auto i : S){ if(i == '!' && (nrH == 0 || nrC == 0)) return -1; else if(i == 'H') ++nrH; else if(i == 'C'){ ++nrC; if(nrC > nrH) return -1; } } for(int i = 0; i < N - 1 ; ++i) if(S[i] == 'H' && S[i + 1] == '!') return -1; if(nrH != nrC) return -1; for(int i = 0; i < N ; ++i){ int nr = 0; while(i < N && S[i] == 'H') ++nr, ++i; if(nr < 2) continue ; nr = 0; while(i < N && S[i] == 'C') ++nr, ++i; if(nr >= 2) return 0; } int st = 0, dr = N; while(st <= dr){ int mij = (st + dr) / 2; int nr = 0, f = 0; bool ok = true; for(int i = N - 1; i >= 0 ; --i){ if(S[i] == '!') ++nr; else if(S[i] == 'C') nr -= mij; if(nr < 0) {ok = false; break ;} } if(ok) st = mij + 1; else dr = mij - 1; } return dr; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 25 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 3200 KB | Output is correct |
9 | Correct | 25 ms | 3328 KB | Output is correct |
10 | Correct | 13 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 | 6 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 25 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 3200 KB | Output is correct |
9 | Correct | 25 ms | 3328 KB | Output is correct |
10 | Correct | 13 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 | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 5 ms | 640 KB | Output is correct |
19 | Correct | 17 ms | 3328 KB | Output is correct |
20 | Incorrect | 21 ms | 3328 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |