| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 38428 | 23级徐泽厚 | 【J】T2 | C++ | 运行出错 | 0 | 28 MS | 2992 KB | 1396 | 2025-10-08 14:02:34 |
#include <bits/stdc++.h> // #define int long long using namespace std; int n,m,T; int x,qs; int p[100005]; vector<int> mp[100005]; int vs[100005]; signed main(){ // ios::sync_with_stdio(0); // cin.tie(0);cout.tie(0); cin>>n>>m>>T; for (int i=1;i<=n;i++){ cin>>p[i]; } for (int i=1;i<=m;i++){ int u,v; cin>>u>>v; mp[u].push_back(v); mp[v].push_back(u); } while (T--){ cin>>x>>qs; if (p[x]>=qs){ cout<<"0\n"; continue; } queue<pair<int,int> > q; memset(vs,0,sizeof(vs)); q.push({x,0}); vs[x]=1; int ans=1000000001; while (!q.empty()){ auto hd=q.front(); q.pop(); for (int i=0;i<mp[hd.first].size();i++){ if (!vs[mp[hd.first][i]]){ vs[mp[hd.first][i]]=1; int lans=hd.second+1; if (p[mp[hd.first][i]]>=qs){ ans=min(ans,lans); } else{ q.push({mp[hd.first][i],lans}); } } } } if (ans==1000000001){ cout<<"-1\n"; } else{ cout<<ans<<"\n"; } } return 0; }