牛客练习赛64 - B Dis2（树，基础图论）

B Dis2

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<vector>
#include<unordered_map>
#define ls (p<<1)
#define rs (p<<1|1)
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#define over(i,s,t) for(register int i = s;i <= t;++i)
#define lver(i,t,s) for(register int i = t;i >= s;--i)
//#define int __int128
using namespace std;
#undef mid
typedef long long ll;
typedef pair<int,int> PII;

const int N = 30007;
const ll mod = 1e9+7;
const ll INF = 1e15+7;
const double EPS = 1e-10;
const int base = 131;

int n,m;
vector<int>edge[N];
int main()
{
scanf("%d",&n);
over(i,1,n-1){
int u,v;
scanf("%d%d",&u,&v);
edge[u].push_back(v);
edge[v].push_back(u);
}
over(i,1,n){
int ans = 0;
for(int j = 0;j<edge[i].size();++j){
ans += edge[edge[i][j]].size()-1;
}
printf("%d\n",ans);
}
return 0;
}


09-22 109

04-18 318

04-24 87

09-22 295

04-14 35

05-05 35

05-23 78

09-24 115

08-11 99

07-02 109

04-02 71

03-31 18

04-14 60万+

03-13 15万+

02-19 18万+

03-01 14万+

03-04 14万+

03-06 4117

03-08 7万+

04-25 7万+

03-10 13万+

03-10 19万+

03-12 11万+

03-13 12万+

03-16 3267

03-18 1万+

03-19 9万+

03-19 4万+

03-20 1万+

03-22 5万+

男生更看重女生的身材脸蛋，还是思想？

©️2019 CSDN 皮肤主题: 酷酷鲨 设计师: CSDN官方博客