Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
37091 22级廖思学 【S】T2 C++ 通过 100 27 MS 2596 KB 733 2025-03-02 16:12:37

Tests(50/50):


#include<bits/stdc++.h> using namespace std; const int N=2e5+10; int id,n,m,a[N],q[N],fr,bc,d[N]; signed main(){ // freopen("restorer.in","r",stdin); // freopen("restorer.out","w",stdout); scanf("%d%d%d",&id,&n,&m); for(int i=1;i<=n;i++)scanf("%d",&a[i]); q[++fr]=1;bc=1;d[1]=0; int k=2; while(k<=n){ int now=q[fr];fr++;//cout<<"???"<<now<<endl; int ls=a[k]; while(k<=n&&a[k]>=ls){ // cout<<k<<" "; d[a[k]]=d[now]+1; q[++bc]=a[k]; ls=a[k];k++; }//cout<<endl; } // for(int i=1;i<=bc;i++)cout<<q[i]<<" ";cout<<endl; printf("%d\n",d[q[bc]]); fclose(stdin);fclose(stdout); return 0; }


测评信息: