题解 | #谁是你的潜在朋友#
谁是你的潜在朋友
https://www.nowcoder.com/practice/0177394fb25b42b48657bc2b1c6f9fcc
#include "stdio.h"
#include "vector"
using namespace std;
int main(){
int N,M;//N为读者数,M为图书数
int student[210];//记录每个学生喜欢的图书号
vector<int> graph[210];//用向量模拟每个图书对应的学生
while (scanf("%d %d",&N,&M)!=EOF){
for (int i = 0; i < N; ++i) {
scanf("%d",&student[i]);
graph[student[i]].push_back(i);
}
for (int i = 0; i < N; ++i) {
if (graph[student[i]].size() == 1)
printf("BeiJu\n");
else
printf("%d\n",graph[student[i]].size()-1);
}
}
}