st表求救!!
  • 板块学术版
  • 楼主HX_ztx
  • 当前回复7
  • 已保存回复7
  • 发布时间2023/12/4 21:53
  • 上次更新2023/12/5 13:19:24
查看原帖
st表求救!!
945933
HX_ztx楼主2023/12/4 21:53

题目

我的 codecode WA了40_{WA了40}

#include<bits/stdc++.h>
using namespace std;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int n,m,st[9999999][33];
int main(){
	n=read();m=read();
	for(int i=1;i<=n;i++)st[i][0]=read();
	for(int k=1;(1<<k)<=n;k++){
		for(int i=1;i+(1<<k)-1<=n;i++){
			st[i][k]=min(st[i][k-1],st[i+(1<<(k-1))][k-1]);
		}
	}
	int r=n-m+1;
	for(int i=1;i<=r;i++){
		int p=log2(n-i+1);
		cout<<min(st[i][p],st[n-(1<<p)+1][p])<<endl;
	}
}

栓q了!!

2023/12/4 21:53
加载中...