#include <cstdio>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include <map>
#include <vector>
#include <climits>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <cctype>
#include <bitset>
#include <iomanip>
#include <cstring>
#include <numeric>
#include <cassert>
using namespace std;
#define int long long
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
int32_t main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m, q, a, b;
cin>>n>>m>>q;
vector<int> vect(m, LLONG_MAX/2), query(q), ans(q, 0);
vector<vector<pii> > graph(n+1);
for (int i=0; i<m; ++i){
cin>>a>>b;
graph[a].pb(mp(b, i));
graph[b].pb(mp(a, i));
}
for (int i=0; i<q; ++i)cin>>query[i], vect[query[i]-1]=i;
priority_queue<pair<pii, int>, vector<pair<pii, int> >, greater<pair<pii, int> > > pq;
vector<pii> dj(n+1, mp(LLONG_MAX/2, LLONG_MAX/2));
pq.push(mp(mp(0, LLONG_MIN/2), 1));
while (pq.size()){
pii d=pq.top().fi;
int node=pq.top().se;
pq.pop();
if (d>=dj[node])continue;
dj[node]=d;
if (-d.se<q)++ans[-d.se];
for (auto num:graph[node])pq.push(mp(mp(d.fi+1, max(d.se, -vect[num.se])), num.fi));
}
for (int i=0, sum=0; i<q; ++i)sum+=ans[i], cout<<sum<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |