hiho week 58 register

Ended

Participants:384

Verdict:Accepted
Score:100 / 100
Submitted:2015-08-09 20:03:17

Lang:GCC

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include <string.h>
char s[10 * 1024 * 1024];
int judge(const char *s) {
    char last = *s++, in;
    int state = 0, count[3] = {1};
    while ((in = *s++)) {
        if (in == last) {
            ++count[state];
            if (state > 0 && count[state] > count[state - 1]) {
                count[0] = count[state];
                state = 0;
            }
        } else if (in == last + 1) {
            if (state == 2)  /*left shift array count*/
                count[0] = count[1], count[1] = count[2];
            else
                ++state;
            count[state] = 1;
        } else {
            state = 0;
            count[state] = 1;
        }
        if (state == 2 && count[state] == count[state - 1])
            return 1;
        last = in;
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX