AcWing 3404. 谁是你的潜在朋友
原题链接
简单
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int N = 1e6+10;
int t,n,m,k,l,r,op,x,y;
int f[N];
unordered_map<int,vector<int>>mp;
void solve(){
cin>>n>>m;
for(int i = 1;i<=n;i++){
cin>>x;
mp[x].push_back(i);
}
for(auto&[k,v]:mp){
for(int num:v){
f[num] = v.size()-1;
}
}
for(int i = 1;i<=n;i++){
if(f[i]==0)cout<<"BeiJu";
else cout<<f[i];
cout<<"\n";
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}