NOIP模板复习 _ ST表 – [模板]

#include 
#define min(a, b) ((a)<(b)?(a):(b))
int f[20][100010], lg[100010];
inline int query(int l, int R) {
    int len = lg[R-l+1], r = R-(1<>1]+1;
    for(int i = 1; i <= 16; i ++ ) for(int j = 1; j <= n; j ++ ) {
        f[i][j] = min(f[i-1][j], f[i-1][j+(1<<(i-1))]);
    }
    int l, r; scanf("%d%d", &l, &r);
    printf("%d", query(l, r));
    while(Q -- ) {
        scanf("%d%d", &l, &r);
        printf(" %d", query(l, r));
    }
}

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注