EntropyIncreaser

staticlca

Nov 15th, 2018
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <ctime>
  4. #include <cstring>
  5. #include <cstdlib>
  6.  
  7. #include <algorithm>
  8. #include <numeric>
  9. #include <limits>
  10. #include <functional>
  11. #include <stack>
  12. #include <vector>
  13. #include <set>
  14. #include <map>
  15. #include <queue>
  16.  
  17. #define LOG(FMT...) fprintf(stderr, FMT)
  18.  
  19. using namespace std;
  20.  
  21. typedef long long ll;
  22. typedef unsigned long long ull;
  23.  
  24. const int N = 500100;
  25.  
  26. namespace Tree {
  27. struct Edge {
  28. int v;
  29. Edge* next;
  30. };
  31.  
  32. int n, s;
  33.  
  34. Edge* g[N];
  35.  
  36. void adde(int u, int v) {
  37. static Edge pool[N * 2];
  38. static Edge* p = pool;
  39. p->v = v;
  40. p->next = g[u];
  41. g[u] = p;
  42. ++p;
  43. }
  44.  
  45. namespace StaticLCA {
  46. const int L = 20;
  47.  
  48. int lgn;
  49.  
  50. int tour[N];
  51. int typ[N / L];
  52. int discst[N / L][L];
  53. int pre[1 << (L >> 1)][L >> 1][L >> 1];
  54.  
  55. void dfs(int u) {
  56.  
  57. }
  58.  
  59. void build() {
  60. while ((1 << lgn))
  61. }
  62.  
  63. int lca(int u, int v) {
  64.  
  65. return 0;
  66. }
  67. }
  68. }
  69.  
  70. int main() {
  71. #ifdef LBT
  72. freopen("test.in", "r", stdin);
  73. int nol_cl = clock();
  74. #endif
  75.  
  76. int m;
  77. scanf("%d%d%d", &Tree::n, &m, &Tree::s);
  78. for (int rep = 1; rep < Tree::n; ++rep) {
  79. int u, v;
  80. scanf("%d%d", &u, &v);
  81. Tree::adde(u, v);
  82. Tree::adde(v, u);
  83. }
  84. Tree::StaticLCA::build();
  85. while (m--) {
  86. int u, v;
  87. scanf("%d%d", &u, &v);
  88. printf("%d\n", Tree::StaticLCA::lca(u, v));
  89. }
  90.  
  91. #ifdef LBT
  92. LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
  93. #endif
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment