文章
27
粉丝
0
获赞
130
访问
8.3k
求助我这个为什么会报运行时错误呀, 通过率50%
#include<bits/stdc++.h>
using namespace std;
void bfs(int s, int t, int& ans) {
vector<int> visit(200001, 0);
if(s == t) return;
queue<int> q;
q.push(s);
visit[s] = 1;
q.push(-999999);
while(!q.empty()) {
int a = q.front();
q.pop();
if(a == -999999) {
q.push(-999999);
ans++;
a = q.front();
q.pop();
}
if(a == t) {
&nb...
登录后发布评论
队列的元素反复入队有问题,另外a-1>=0,修改后代码