| 比赛 |
2026.9.5 |
评测结果 |
WAAAAAWWWWWWWWWWWWWWWWWWW |
| 题目名称 |
Tree Decorations |
最终得分 |
20 |
| 用户昵称 |
Ruyi |
运行时间 |
2.414 s |
| 代码语言 |
C++ |
内存使用 |
21.70 MiB |
| 提交时间 |
2026-09-05 12:59:54 |
显示代码纯文本
#include<bits/stdc++.h>
#define ll long long
#define N 500001
using namespace std;
ll n,m,u,v,siz[N],id,maxx,son[N];
vector<ll> e[N];
ll read(){
ll x=0,f=1;
char c=' ';
while(c>'9'||c<'0'){
if(c=='-') f=-1;
c=getchar();
}
while(c>='0'&&c<='9'){
x=x*10+(c-'0');
c=getchar();
}
return x*f;
}
void write(ll x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
void dfs(ll x,ll fa){
siz[x]=1;
for(auto i:e[x])
if(i!=fa){
son[x]++;
dfs(i,x);
siz[x]+=siz[i];
}
if(fa==1&&siz[x]>maxx){
maxx=siz[x];
id=x;
}
return ;
}
int main(){
freopen("Decorations.in","r",stdin);
//freopen("d1p2.2-25.in","r",stdin);
freopen("Decorations.out","w",stdout);
n=read();
m=read();
for(int i=1;i<n;i++){
u=read();
v=read();
e[u].push_back(v);
e[v].push_back(u);
}
write(1);
return 0;
}