标签:col define include test 一个 back 包含 cto alt
链接:https://ac.nowcoder.com/acm/contest/3002/G
题目描述
#include <bits/stdc++.h> #define inf 0x3f3f3f3f #define INF 0x7fffffffffffffff typedef long long ll; const double PI=3.1415926535897931; const long long mod=1e9+7; const int MA= 1e7+10; const int ma= 2*1e5+10; const int few=1e3+10; using namespace std; ////////////////////////////////////////////// int main() { int n,k,ans=inf; string s; cin>>n>>k; cin>>s; vector<int> a[26]; for(int i=0; i<s.size(); i++) { int x=s[i]-‘a‘; a[x].push_back(i); int len=a[x].size(); if(len>=k) ans=min(ans,i-a[x][len-k]+1); } if(ans==inf) cout<<"-1"<<endl; else cout<<ans<<endl; return 0; }
标签:col define include test 一个 back 包含 cto alt
原文地址:https://www.cnblogs.com/Aracne/p/12262859.html