Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
28187 | LYLAKIOI | 【BJ】T2 | C++ | 解答错误 | 5 | 3 MS | 6124 KB | 1101 | 2024-04-04 20:50:25 |
#include<bits/stdc++.h> #define up(i,l,r) for(int i=(l);i<=(r);++i) #define down(i,l,r) for(int i=(l);i>=(r);--i) #define p_b push_back #define m_p make_pair #define pi pair<int,int> #define p1 first #define p2 second #define int long long using namespace std; typedef long long ll; typedef unsigned long long ull; const int maxn=2.5e5+10,mod=1e9+7; const ll inf=1e18; inline ll read(){ ll x=0;short t=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')t=-1;ch=getchar(); }while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*t; } int n,K; vector<int>v[maxn]; int dfs(int u,int fa){ int g=0; for(int x:v[u])if(x!=fa){ int val=dfs(x,u); if(val==2)return 2; if(val)g++; } if(!g)return 1; if(g==1)return 0; return 2; } void slv(){ n=read(),K=read();up(i,1,n)v[i].clear(); up(i,1,n-1){ int x=read(),y=read(); v[x].p_b(y),v[y].p_b(x); } if(n&1)printf("Alice\n"); else if(dfs(1,0)==2)printf("Alice\n"); else if(K<n/2)printf("Alice\n"); else printf("Bob\n"); }signed main(){ int t=read();while(t--)slv(); return 0; }