Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
37067 | 22fhq | 【S】T2 | C++ | 通过 | 100 | 35 MS | 14280 KB | 1441 | 2025-03-02 15:11:47 |
#include<bits/stdc++.h> #define int long long using namespace std; void read(int &x){x=0;char c=getchar();bool neg=0;while(!isdigit(c)){if(c=='-')neg=1;c=getchar();}while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();if(neg)x=-x;} #define read2(a,b) read(a),read(b) #define read3(a,b,c) read(a),read(b),read(c) #define read4(a,b,c,d) read(a),read(b),read(c),read(d) #define read5(a,b,c,d,e) read(a),read(b),read(c),read(d),read(e) #define read6(a,b,c,d,e,f) read(a),read(b),read(c),read(d),read(e),read(f) int id,n,m,a[200005],top; vector<int>e[200005]; void bfs(){ queue<int>q; q.push(1); top=2; while(!q.empty()){ int u=q.front();q.pop(); if(top<=n){ e[u].push_back(a[top]); q.push(a[top]); top++; } while(a[top]>a[top-1]&&top<=n)e[u].push_back(a[top]),q.push(a[top++]); } } int dp[200005]; void dfs(int p,int f){ for(int x:e[p]){ if(x==f)continue; dp[x]=dp[p]+1; dfs(x,p); } } void slv(){ read3(id,n,m); for(int i=1;i<=n;i++)read(a[i]); bfs(); // for(int i=1;i<=n;i++){ // cout<<e[i].size()<<" "; // for(int x:e[i])cout<<x<<" "; // cout<<endl; // } dfs(1,0); int ans=0; for(int i=1;i<=n;i++)ans=max(ans,dp[i]); cout<<ans<<endl; } signed main(){ // int T;read(T);while(T--) slv(); return 0; } //