直接存映射

#include <iostream>
using namespace std;

const int N = 210;
int a[N], b[N];

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", &a[i]);
        ++b[a[i]];
    }
    for (int i = 0; i < n; ++i)
    {
        if (b[a[i]] == 1)
            printf("BeiJu\n");
        else
            printf("%d\n", b[a[i]] - 1);
    }
    return 0;
}