正文
增加 0 行删除 42 行
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748735 行未改动全部展开### ST表模板:```cpp/*P.S:This program can AC P3865*/#include<bits/stdc++.h>using namespace std;#define int long longconst int N = 1e5+10;int Log2[N];const int M = 30;int f[N][M];int n,m;void init(){Log2[1] =0;for(int i = 2;i<=n;i++){Log2[i] = Log2[i >> 1] + 1;}for(int j = 1;j<=Log2[n];j++){for(int i = 1;i + (1 << j) -1 <= n;i++){f[i][j] = max(f[i][j - 1],f[i + (1 << (j - 1))][j - 1]);}}}signed main(){ios::sync_with_stdio(0);cin.tie(0);cin>>n>>m;for(int i =1;i<=n;i++){cin>>f[i][0];}init();while(m--){int l,r;cin>>l>>r;int k = Log2[r - l + 1];cout<<max(f[l][k],f[r - (1 << k) + 1][k])<<'\n';}return 0;}``````cpp#include<bits/stdc++.h>using namespace std;#define int long long735 行未改动全部展开123456735 行未改动全部展开### ST表模板:```cpp#include<bits/stdc++.h>using namespace std;#define int long long735 行未改动全部展开