hiho week 58 register

Ended

Participants:384

Verdict:Accepted
Score:100 / 100
Submitted:2015-08-08 21:04:37

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include<bits/stdc++.h>
using namespace std;
#define bufs 10*1024*1024+1
char buf[bufs],uni[bufs];int c[bufs];
#define PN puts("NO")
#define PY puts("YES")
int main() {
    int T,len,z;scanf("%d",&T);
    while (T--) {
        scanf("%d%s",&len,buf);
        z=0;memset(c,0,sizeof(c));
        if (len<3) { PN;continue; }
        for (int k=0;k<len;++k)if (uni[z]!=buf[k])uni[++z]=buf[k];else ++c[z];
        uni[++z]=0;//uni[0]='A';
        //cout<<uni<<z<<endl;
        if (z<4) { PN;continue; }
        for (int i=3;i<z;++i)if (uni[i]-1==uni[i-1]&&uni[i]-2==uni[i-2]
            &&c[i]>=c[i-1]&&c[i-1]<=c[i-2]) { PY;goto nx; }
        PN;
    nx:;
    }
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX