#include #include #include using namespace std;

const int N = 1010; int n, m; int fans[N], follow[N]; vector v[N]; // 存储每个人的粉丝列表

int main() { cin >> n >> m; while (m -- ) { int a, b; cin >> a >> b; // 更新每个人的粉丝列表和关注数 v[b].push_back(a); follow[a] ++ ; }

for (int i = 0; i < n; i ++ )
    for (auto f : v[i])  // 计算每个人的粉丝数
        fans[i] ++ ;

for (int i = 0; i < n; i ++ )
    cout << fans[i] - follow[i] << endl;

return 0;
请用写出以下题目完整的C++代码:蒜头君和他的同事们最近在玩一个好玩的游戏:互粉攻略。一共有 NN 个人参加游戏编号从 00 到 N - 1N−1游戏前每个人都会展示自己最靓丽的一面。当游戏开始时每个人可以选择去关注别人。当 AA 关注了 BB则 AA 就成了 BB 的粉丝但是并不意味着 BB 同时关注了 AA。当所有人都选好后游戏结束人气指数最高的人成为冠军。蒜头君制定了奇怪的规定:一个人的人气

原文地址: https://www.cveoy.top/t/topic/eiog 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录