上课闲的没事想到的题,挺水的。。。

只需要计算出每个数被除了多少次,就是优先级的最长下降子序列

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define N 5000005
using namespace std;
int n,a[N],q[N],top,ans[N],t;
int read(){
	int a=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){a=a*10+ch-'0';ch=getchar();}
	return a;
}
int main(){
	freopen("divid.in","r",stdin);
	freopen("divid.out","w",stdout);
	n=read();t=read();
	for(int i=1;i<=n-1;i++)a[i]=read();
	for(int i=1;i<n;i++){
		while(top&&a[i]>q[top])top--;
		q[++top]=a[i];
		ans[i+1]=top;
	}
	for(int i=t;i<=n;i+=t)
		printf("%d",ans[i]%2);
	return 0;
}


相关文章:

  • 2021-10-14
  • 2021-06-01
  • 2022-02-27
  • 2022-12-23
  • 2021-07-20
  • 2021-12-20
  • 2021-07-16
  • 2022-02-07
猜你喜欢
  • 2021-08-08
  • 2021-11-27
  • 2021-12-15
  • 2021-09-27
  • 2021-09-30
相关资源
相似解决方案