1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl '\n' #define Turnoff std::ios::sync_with_stdio(false) const ll Max=1e5+5; const ll Mod=998857459;
vector<int>mp[Max]; int Twopoint,fardis,farpoint; void dfs(int now,int fa,int dis,int to){ if(now==to)Twopoint=dis; if(dis>fardis){ fardis=dis; farpoint=now; } for(auto i:mp[now]){ if(i==fa)continue; dfs(i,now,dis+1,to); } } int main() { Turnoff; int t;cin>>t; while(t--){ int n,a,da,b,db; cin>>n>>a>>b>>da>>db; for(int i=1;i<n;i++){ int u,v;cin>>u>>v; mp[u].push_back(v); mp[v].push_back(u); } fardis=0,farpoint=a; dfs(a,0,0,b); if(Twopoint<=da)cout<<"Alice"<<endl; else{ dfs(farpoint,0,0,0); if(fardis<=2*da||2*da>=db)cout<<"Alice"<<endl; else cout<<"Bob"<<endl; } for(int i=1;i<=n;i++)mp[i].clear(); } }
|