实际上1*n的地图。。不就是线性的么。。
1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 #include<algorithm> 6 #include<cmath> 7 using namespace std; 8 int n,m,ans; 9 int f[270000][66],a[270000]; 10 int main(){ 11 scanf("%d",&n); 12 for (int i=1;i<=n;i++){ 13 scanf("%d",&a[i]); 14 f[i][a[i]]=i+1; 15 } 16 for (int j=2;j<=60;j++) 17 for (int i=1;i<=n;i++){ 18 if (f[i][j]==0) f[i][j]=f[f[i][j-1]][j-1]; 19 if (f[i][j]>0) ans=max(ans,j); 20 } 21 printf("%d\n",ans); 22 return 0; 23 }
原文地址:https://www.cnblogs.com/hahaha2124652975/p/11231072.html
时间: 2024-11-09 09:40:09