hiho week 229 register

Ended

Participants:105

Verdict:Accepted
Score:100 / 100
Submitted:2018-11-20 13:00:59

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
23
24
25
26
27
28
29
30
31
#include<bits/stdc++.h>
using namespace std;
int num[30];
string s;
bool check(int i, int j, int n) {
    for (int c = 0; c < 26; c++) {
        int len = j-i+1,t = 0;
        if (num[c] >= len) {
            for (int p = i; p <= j; p++) {
                if (s[p]-'a' != c ) t++;
            }
            if (t <= n) return true;
        }
    }
    return false;
}
int main() {
    int n;
    while(cin >> n >> s){
            int len = s.size();
            memset(num, 0, sizeof(num));
            for (int i = 0; i < len; i++) {
                  num[s[i]-'a']++;
            }
            int ans = 0;
            int i = 0,j = 1;
            while(i < len && j < len) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX