记录编号 450749 评测结果 AAAAAAAAAA
题目名称 [HZOI 2017] 守规矩 最终得分 100
用户昵称 GravatarHzoi_Ivan 是否通过 通过
代码语言 C++ 运行时间 1.564 s
提交时间 2017-09-16 18:02:08 内存使用 57.54 MiB
显示代码纯文本
  1. #include<cstdio>
  2. #include<cstring>
  3. #include<iostream>
  4. #include<algorithm>
  5. #include<cmath>
  6. #define N 5000005
  7. using namespace std;
  8. int n,a[N],q[N],top,ans[N],t;
  9. int read(){
  10. int a=0;char ch=getchar();
  11. while(ch<'0'||ch>'9')ch=getchar();
  12. while(ch>='0'&&ch<='9'){a=a*10+ch-'0';ch=getchar();}
  13. return a;
  14. }
  15. int main(){
  16. freopen("divid.in","r",stdin);
  17. freopen("divid.out","w",stdout);
  18. n=read();t=read();
  19. for(int i=1;i<=n-1;i++)a[i]=read();
  20. for(int i=1;i<n;i++){
  21. while(top&&a[i]>q[top])top--;
  22. q[++top]=a[i];
  23. ans[i+1]=top;
  24. }
  25. for(int i=t;i<=n;i+=t)
  26. printf("%d",ans[i]%2);
  27. return 0;
  28. }