#include<bits/stdc++.h> using namespace std; const int N=1e5+10; long long cnt[2]; signed main(){ int n,a,b; cin>>n>>a>>b; string s;cin>>s; s=" "+s; long long res=0; if(a==0&&b==0) { res++; } for(int i=1,j=0;i<=n;i++){ int t=0; if(s[i]=='0') t=0; else t=1; while(j<n&&(cnt[0]<a||cnt[1]<b) ){ j++; cnt[s[j]-'0']++; } if((cnt[0]>=a&&cnt[1]>=b)) res+=n-j+1; cnt[s[i]-'0']--; } cout<<res; return 0; }就这几行代码 但就是不知道怎么弄那个特判 难道不是a=0 b=0 答案数+1吗?
全部评论
(1) 回帖