正文
增加 8 行删除 8 行
112 行未改动全部展开1131141151161171181191201214 行未改动1261271281291301311321331343 行未改动13813914014114214314414514613 行未改动16016116216316416516616716841 行未改动21021121221321421521621721821928 行未改动2482492502512522532542552562572582592602618 行未改动112 行未改动全部展开{node tmp = q.front() ;q.pop() ;int nx = tmp.x , ny = tmp.y ;if(nx == n && ny == m){return ;//不用额外输出}for(int i = 0 ; i < 4 ; i++)4 行未改动if(a[xx][yy] == '*') continue ;if(f[xx][yy] == true) continue ;f[xx][yy] = true ;pre[xx][yy] = {nx , ny} ;//存入上一步q.push({xx , yy , tmp.step + 1})}}}int main()3 行未改动{for(int j = 1 ; j <= m ; j++){cin >> a[i][j] ;}}bfs(1 , 1) ;//调用bfs函数st.push({n , m}) ;int l = pre[n][m].xx , r = pre[n][m].yy ;13 行未改动cout << st.top().xx << " " << st.top().yy << endl ;st.pop() ;//弹出}return 0 ;}```# P4328 [COCI 2006/2007 #1] Slikar41 行未改动void bfsr()//算最少时间的bfs{while(q.size() > 0){node tmp = q.front() ;if(tmp.x == ax && tmp.y == ay){cout << fr[tmp.x][tmp.y] ;return ;}28 行未改动{ax = i ;ay = j ;}if(s[i][j] == '*'){h.push({i , j}) ;fh[i][j] = 0 ;}if(s[i][j] == 'S'){q.push({i , j}) ;fr[i][j] = 0 ;}8 行未改动112 行未改动全部展开1131141151161171181191201214 行未改动1261271281291301311321331343 行未改动13813914014114214314414514613 行未改动16016116216316416516616716841 行未改动21021121221321421521621721821928 行未改动2482492502512522532542552562572582592602618 行未改动112 行未改动全部展开{node tmp = q.front() ;q.pop() ;int nx = tmp.x , ny = tmp.y ;if(nx == n && ny == m){return ;//不用额外输出}for(int i = 0 ; i < 4 ; i++)4 行未改动if(a[xx][yy] == '*') continue ;if(f[xx][yy] == true) continue ;f[xx][yy] = true ;pre[xx][yy] = {nx , ny} ;//存入上一步q.push({xx , yy , tmp.step + 1})}}}int main()3 行未改动{for(int j = 1 ; j <= m ; j++){cin >> a[i][j] ;}}bfs(1 , 1) ;//调用bfs函数st.push({n , m}) ;int l = pre[n][m].xx , r = pre[n][m].yy ;13 行未改动cout << st.top().xx << " " << st.top().yy << endl ;st.pop() ;//弹出}return 0 ;}```# P4328 [COCI 2006/2007 #1] Slikar41 行未改动void bfsr()//算最少时间的bfs{while(q.size() > 0){node tmp = q.front() ;if(tmp.x == ax && tmp.y == ay){cout << fr[tmp.x][tmp.y] ;return ;}28 行未改动{ax = i ;ay = j ;}if(s[i][j] == '*'){h.push({i , j}) ;fh[i][j] = 0 ;}if(s[i][j] == 'S'){q.push({i , j}) ;fr[i][j] = 0 ;}8 行未改动