版本比较
1.25j组训练营总结
正文
增加 8 行删除 8 行
112 行未改动全部展开1131141151161171171181191201214 行未改动1261271281291301301311321331343 行未改动13813914014114214214314414514613 行未改动16016116216316416416516616716841 行未改动21021121221321421521421521621721821928 行未改动2482492502512522522532542552562572572582592602618 行未改动112 行未改动全部展开 { node tmp = q.front() ; q.pop() ; int nx = tmp.x , ny = tmp.y ; if(nx == n && ny == m) 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}) 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] Slikar
41 行未改动void bfsr()//算最少时间的bfs{ while(q.size() > 0) { node tmp = q.front() ; if(tmp.x == ax && tmp.y == ay) 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] == '*') if(s[i][j] == '*') { h.push({i , j}) ; fh[i][j] = 0 ; } if(s[i][j] == 'S') if(s[i][j] == 'S') { q.push({i , j}) ; fr[i][j] = 0 ; }8 行未改动