AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 应用
  • 更多
    • 题解
    • 分享
    • 商店
    • 吐槽
  • App
  • 登录/注册

AcWing 4960. 子串简写

作者: 作者的头像   炽热的 ,  2023-05-13 14:59:39 ,  所有人可见 ,  阅读 62


2


#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 500010;

int n, k;
char a, b, s[N];

int main() {
    cin >> k >> s + 1 >> a >> b;

    n = strlen(s + 1);
    long long ans = 0;
    int cnt = 0;
    for (int i = k; i <= n; i ++ ) {
        if (s[i - k + 1] == a) cnt ++ ;
        if (s[i] == b) ans += cnt;
    }

    cout << ans;

    return 0;
}

1 评论


用户头像
我只想摸鱼   4个月前         踩      回复

厉害


你确定删除吗?
1024
x

© 2018-2023 AcWing 版权所有  |  京ICP备2021015969号-2
用户协议  |  隐私政策  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标 qq图标
请输入绑定的邮箱地址
请输入注册信息