题解 | #谁是你的潜在朋友#
谁是你的潜在朋友
http://www.nowcoder.com/practice/0177394fb25b42b48657bc2b1c6f9fcc
直接存映射
#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;
}