fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define max 450001
  4. typedef long long ll;
  5. ll shade[max];
  6. vector<ll> vec[max];
  7. bool visit[max];
  8. /*bool bfs(ll source,ll dest,ll nodes,ll pred[])
  9. {
  10. for(ll i=0;i<nodes+1;++i){
  11. visit[i]=false;
  12. }
  13. queue<ll> q;
  14. visit[source]=true;
  15. q.push(source);
  16. while(!q.empty()){
  17. ll x=q.front();
  18. q.pop();
  19. for(ll i=0;i<vec[x].size();++i){
  20. if(visit[vec[x][i]]==false){
  21. q.push(vec[x][i]);
  22. pred[vec[x][i]]=x;
  23. if(vec[x][i]==dest)
  24. return true;
  25. }
  26.  
  27. }
  28. }
  29. return false;
  30.  
  31. }*/
  32. /*ll num(ll src,ll dest,ll nodes)
  33. {
  34. ll pred[nodes+1];
  35. for(ll i=0;i<nodes+1;++i){
  36. pred[i]=-1;
  37. }
  38. bfs(src,dest,nodes,pred);
  39. ll p=dest;
  40. while(pred[p]!=-1){
  41. cout<<pred[p];
  42. p=pred[p];
  43. }
  44. }*/
  45. int main() {
  46. int t;
  47. cin>>t;
  48. while(t--){
  49. ll n,q,r,i;
  50. cin>>n>>q>>r;
  51. for( i=0;i<n;++i){
  52. ll s;
  53. cin>>s;
  54. shade[i]=s;
  55. }
  56. for( i=0;i<n-1;++i){
  57. ll p,q;
  58. cin>>p>>q;
  59. vec[p].push_back(q);
  60. vec[q].push_back(p);
  61. }
  62. /* for(ll j=0;j<q;++j){
  63. ll a,b;
  64. cin>>a>>b;
  65. cout<<num(a,b,n);
  66. }*/
  67. }
  68. return 0;
  69. }
Runtime error #stdin #stdout 0s 29736KB
stdin
1
311
123
12
23
stdout
Standard output is empty