fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long int
  4.  
  5. vector<int> d;
  6. vector< vector<int> > v;
  7.  
  8. void dfs(int u, int p)
  9. {
  10. if(p!=-1)d[u] = d[p]+1;
  11. for(int i: v[u])
  12. {
  13. if(i==p)continue;
  14. dfs(i, u);
  15. }
  16. }
  17.  
  18. #undef int
  19. int main()
  20. {
  21. #define int long long int
  22. ios_base::sync_with_stdio(0);
  23. cin.tie(0);
  24. cout.tie(0);
  25.  
  26. int n;
  27. cin>>n;
  28. v.resize(n);
  29. d.resize(n);
  30. for(int i = 0;i<n-1;i++)
  31. {
  32. int x, y;
  33. cin>>x>>y;
  34. v[x-1].push_back(y-1);
  35. v[y-1].push_back(x-1);
  36. }
  37. d[0] = 0;
  38. dfs(0, -1);
  39. int q;
  40. cin>>q;
  41. while(q--)
  42. {
  43. int x, y;
  44. cin>>x>>y;
  45. if((d[x-1]+d[y-1])&1)cout<<"Odd"<<endl;
  46. else cout<<"Even"<<endl;
  47. }
  48.  
  49.  
  50. return 0;
  51. }
Runtime error #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty