P3146 [USACO16OPEN]248
作者:互联网
实际上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 }
标签:printf,P3146,int,270000,USACO16OPEN,ans,include,248 来源: https://www.cnblogs.com/hahaha2124652975/p/11231072.html