离谱

P3865 【模板】ST 表

cin cout都不要了 cin换快读 cout换printf 然后把你的 ```ios::sync_with_stdio``` 删掉试试?
by 233小问号 @ 2021-07-21 16:38:04


@[233小问号](/user/332486) 根据某大佬的测试,cin优化后比scanf快?
by wbs200 @ 2021-07-21 16:39:10


感觉可能是您快读写挂了 ```cpp #include<bits/stdc++.h> using namespace std; const int N=1e5+5; int dp[N][30],b[N]; int gi() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = 0; c = getchar(); } while (c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - 48, c = getchar(); return f ? x : -x; } int main(){ int n = gi(), m = gi(); for(int i=1;i<=n;i++){ dp[i][0] = gi(); b[i]=log2(i); } for(int j=1;(1<<j)<=n;j++){ for(int i=1;i+(1<<j)-1<=n;i++){ dp[i][j]=max(dp[i][j-1],dp[i+(1<<(j-1))][j-1]); //cout<<dp[i][j]<<" "; } } while(m--){ int l = gi(), r = gi(); int j=b[r-l+1]; printf("%d\n", max(dp[l][j],dp[r-(1<<j)+1][j])); } return 0; } ```
by chenyilei @ 2021-07-21 16:39:18


|