如果你使用一个结构体栈来存数据的话,
不要像这样直接套:
struct node{int x,y;};
stack<node>s;
for(int i2=0;i2<4;i2++)
{
int x2=s.top().x+st_x[i2],y2=s.top().y+st_y[i2];
if(x2<1||y2<1||x2>m||y2>n||stop[y2][x2])
continue;
stop[y2][x2]=i+2;
s.push(node{x2,y2});
}
s.pop();
而应该像这样:
struct node{int x,y;};
stack<node>s;
node zzz=s.top();
s.pop();
for(int i2=0;i2<4;i2++)
{
int x2=zzz.x+st_x[i2],y2=zzz.y+st_y[i2];
if(x2<1||y2<1||x2>m||y2>n||stop[y2][x2])
continue;
stop[y2][x2]=i+2;
s.push(node{x2,y2});
}
不要问我怎么知道的!