Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #include <ctime>
- #include <cstring>
- #include <cstdlib>
- #include <algorithm>
- #include <numeric>
- #include <limits>
- #include <functional>
- #include <stack>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #define LOG(FMT...) fprintf(stderr, FMT)
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- const int N = 500100;
- namespace Tree {
- struct Edge {
- int v;
- Edge* next;
- };
- int n, s;
- Edge* g[N];
- void adde(int u, int v) {
- static Edge pool[N * 2];
- static Edge* p = pool;
- p->v = v;
- p->next = g[u];
- g[u] = p;
- ++p;
- }
- namespace StaticLCA {
- const int L = 20;
- int lgn;
- int tour[N];
- int typ[N / L];
- int discst[N / L][L];
- int pre[1 << (L >> 1)][L >> 1][L >> 1];
- void dfs(int u) {
- }
- void build() {
- while ((1 << lgn))
- }
- int lca(int u, int v) {
- return 0;
- }
- }
- }
- int main() {
- #ifdef LBT
- freopen("test.in", "r", stdin);
- int nol_cl = clock();
- #endif
- int m;
- scanf("%d%d%d", &Tree::n, &m, &Tree::s);
- for (int rep = 1; rep < Tree::n; ++rep) {
- int u, v;
- scanf("%d%d", &u, &v);
- Tree::adde(u, v);
- Tree::adde(v, u);
- }
- Tree::StaticLCA::build();
- while (m--) {
- int u, v;
- scanf("%d%d", &u, &v);
- printf("%d\n", Tree::StaticLCA::lca(u, v));
- }
- #ifdef LBT
- LOG("Time: %dms\n", int((clock() - nol_cl) / (double)CLOCKS_PER_SEC * 1000));
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment