牛客小白月赛6 D字符串丝带

版权声明: https://blog.csdn.net/Adusts/article/details/81835433

题目链接:https://www.nowcoder.com/acm/contest/136/D

#include <iostream>
#include <cstring>
#include <cstdio>
#include <map>
using namespace std;
map<char,int>mp;
int ans[1000010];
int main() {
    int n, m, x;
    char s;
    scanf("%d %d", &n, &m);
    getchar();
    for(int i = 1; i <= n; i++) {
        scanf("%c", &s);
        mp[s]++;
        ans[i] = mp[s];
    }
    while(m--) {
        scanf("%d", &x);
        printf("%d\n", ans[x]);
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/Adusts/article/details/81835433