题解:P14503 [NCPC 2025] Instagraph
思路
考虑处理每个人的入度。
当
当之后
代码
#include<bits/stdc++.h>
#define endl "\n"
#define int long long
#define f(n) for(int i=1;i<=n;i++)
#define IOS cin.tie(0),cout.tie(0),ios::sync_with_stdio(0)
using namespace std;
int n,m,x,y,r[200005],maxn=-1,maxi;
map<int,map<int,int>>e;//常数巨大让我拿下当前最劣解
signed main(){
IOS;cin>>n>>m;
f(m){
cin>>x>>y;
if(e[y][x])r[x]--;//y之前关注过x,现在两人互关,去除y对x的贡献
else r[y]++;//x对y贡献一个关注
e[x][y]=1;//记录x关注过y
}
f(n)if(r[i]>maxn)maxn=r[i],maxi=i;//找出最大名人中心性
cout<<maxi<<" "<<maxn;
return 0;
}