HRBUST 2337

#include
#include
#include
#include
#include
#include
using namespace std;
struct node
{
    long num;
    int step;
    int yustep;
    int ci;
};
queueq;
long vis[30005];
int main()
{
   int n;
   long a[30005];
   while(~scanf("%d",&n))
   {
       node s;
       memset(vis,0,sizeof(vis));
       for(int i=0;i=temp.yustep)
           {
               temp.ci = temp.ci + 1;
               pan=2;
               break;
           }
           for(long i=1;i<=temp.num;i++)
           {
               temp1.num = a[temp.step+i];
               if(vis[temp.step+i]!=1){
                vis[temp.step+i]=1;
               temp1.step = temp.step+i;
               temp1.yustep = n-1-temp1.step;
               temp1.ci=temp.ci+1;
               q.push(temp1);
               }
               if(temp1.num>=temp1.yustep)
              {
               temp1.ci = temp1.ci+1;
               pan=1;
               break;
               }

           }
           if(pan==1||pan==2) break;
       }
       if(pan==1)
       printf("%d\n",temp1.ci);
       if(pan==2) printf("%d\n",temp.ci);
   }
   return 0;
}

你可能感兴趣的:(oj)