Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #define N 1111111
- using namespace std;
- string s;
- int n,a[37],l,r,k;
- long long ans;
- int f(char c){
- if (c>='0' && c<='9') return c-'0';
- return c-'a'+10;
- }
- int main(void){
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- cin>>n>>k;
- cin>>s;
- r=-1;
- while (r<n-1){
- ++r;
- if (++a[f(s[r])]>k){
- while (l<r && a[f(s[r])]>k){
- --a[f(s[l])];
- ++l;
- }
- }
- ans+=r-l+1;
- }
- cout<<ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment