题很水啊,只是拿来练习SparseTable,一种tarjan提出的数据结构。
好吧,其实就是倍增思想。因为LCA->RMQ问题中我ST表不会写所以特来练习,水一发。
如果不会ST表的可以看http://blog.csdn.net/niushuai666/article/details/6624672
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 50010;