好像在本版看过这个题 、看到分就来了

404 NOT FOUND
程序代码:
#include<stdio.h>
#include<malloc.h>
void xiu(struct node*,int,int *,struct node *);
struct node
{
int num;
struct node *p[3];
};
int main()
{
int n,m;
scanf("%d %d",&m,&n);
struct node **p1=(struct node **)malloc(sizeof(struct node *)*m);
p1[0]=(struct node *)malloc(sizeof(struct node)*m*n);
for(int y=1;y<m;y++)
p1[y]=p1[y-1]+n;
for(int i=0;i<m;i++)
{
for(int j=0;j<n;j++)
{
scanf("%d",&p1[i][j].num);
for(int l=0;l<3;l++)
p1[i][j].p[l]=NULL;
}
}
for(int k=0;k<m;k++)
{
for(int j=0;j<n;j++)
{int i=0;
if(k!=0)
if(p1[k][j].num>p1[k-1][j].num)
p1[k][j].p[i++]=&p1[k-1][j];
if(k!=m-1)
if(p1[k][j].num>p1[k+1][j].num)
p1[k][j].p[i++]=&p1[k+1][j];
if(j!=n-1)
if(p1[k][j].num>p1[k][j+1].num)
p1[k][j].p[i++]=&p1[k][j+1];
if(j!=0)
if(p1[k][j].num>p1[k][j-1].num)
p1[k][j].p[i]=&p1[k][j-1];
}
}
int *start=(int *)malloc(sizeof(int)*n);
start[0]=0;
struct node *p2;
for(int j=1;j<n;j++)
if(p1[0][start[0]].num<p1[0][j].num)
start[0]=j;
for(int s=1;s<n;s++)
{
start[s]=s;
for(int j=1;j<n;j++)
if(p1[0][start[s]].num<p1[0][j].num && p1[0][j].num<=p1[0][start[s-1]].num)
start[s]=j;
}
int *end=(int *)malloc(sizeof(int)*n);
for(s=0;s<n;s++)
end[s]=0;
for(s=0;s<n;s++)
{ p2=&p1[0][start[s]];
xiu(p2,(m-1)*n,end,p1[0]);
for(int i=0;;i++)
{
if(end[i]==0)
break;
if(i==m-1)
{
printf("\n 1 \n %d",s+1);
return 0;
}
}
}
int c=0;
for(int o=0;o<n;o++)
{
if(end[o]==0)
c++;
}
printf("\n 0 \n %d",c);
return 0;
}
void xiu(struct node *lp,int n,int *end,struct node *p1)
{if((lp-p1)>=n)
end[lp-p1-n]=1;
if(lp->p[0]!=NULL)
xiu(lp->p[0],n,end,p1);
if(lp->p[1]!=NULL)
xiu(lp->p[1],n,end,p1);
if(lp->p[2]!=NULL)
xiu(lp->p[2],n,end,p1);
}再说一下优化问题:我觉得在每个城市都能行的情况下,先一个城市一个城市的试,行的话输出1,不行的话2个城市2个城市的试,行的话输出2,不行就3个城市一起试,依次类推,直到数量达到最大值,这个方法比较笨,但应该可用,但太费时间了。