题解 | #谁是你的潜在朋友#
谁是你的潜在朋友
https://www.nowcoder.com/practice/0177394fb25b42b48657bc2b1c6f9fcc
#include<iostream> #include<queue> #include<vector> using namespace std; struct Collect { priority_queue <int, vector<int>, greater<int>>number; int a = 0; }; Collect Friend[201]; vector<int> reader; void Getf(int i, int num) { Friend[num].number.push(i); Friend[num].a++; } int main() { int n, m; int temp; cin >> n >> m; for (int i = 0; i < n; i++) { cin >> temp; reader.push_back(temp); Getf(i, temp); } for (int i = 0; i < n; i++) { if (Friend[reader[i]].a > 1) cout << (Friend[reader[i]].a - 1) << endl; else cout << "BeiJu" << endl; } system("pause"); return 0; }