如题 这条语句在本地可以通过编译,但放到洛谷IDE/评测机会CE掉 求助
floorBFS.push( pair {target,nextStep} );
完整代码 题目P1135
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,a,b;
int floorChange[N];
bool isVis[N];
queue<pair<int,int> > floorBFS;
int main()
{
cin>>n>>a>>b;
for (int i=1;i<=n;++i) cin>>floorChange[i];
floorBFS.push({a,0});
isVis[a]=1;
while(!floorBFS.empty())
{
int floorNow=floorBFS.front().first;
int totalMove=floorBFS.front().second;
floorBFS.pop();
if (floorNow==b)
{
cout<<totalMove;
return 0;
}
int target,nextStep;
target=floorNow+floorChange[floorNow];
nextStep=totalMove+1;
if (target>=1 && target<=n && isVis[target]==0)
{
isVis[target]=1;
floorBFS.push(pair{target,nextStep});
}
target=floorNow-floorChange[floorNow];
if (target>=1 && target<=n && isVis[target]==0)
{
isVis[target]=1;
floorBFS.push(pair{target,nextStep});
}
}
cout<<"-1";
return 0;
}