#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int MX=100010, inf=2e9;
int n, m, q;
int out_e[2*MX];
int out_v[MX];
int dep[MX];
vector<pii> G[MX];
void solve(){
queue<int> Q;
fill(dep+1, dep+n+1, -1);
dep[1]=0, out_v[1]=q+1; Q.push(1);
while(!Q.empty()){
int v=Q.front(); Q.pop();
for(pii &e:G[v]){
int x, idx; tie(x,idx)=e;
if(dep[x]>=0 && dep[x]<=dep[v]) continue;
if(dep[x]<0){
dep[x]=dep[v]+1;
Q.push(x);
}
out_v[x]=max(out_v[x], min(out_v[v], out_e[idx]));
}
}
int cnt[MX]={};
for(int i=2; i<=n; i++) cnt[out_v[i]]++;
for(int i=1; i<=q; i++) cnt[i]+=cnt[i-1];
for(int i=1; i<=q; i++) cout<<cnt[i]<<'\n';
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>m>>q;
for(int i=1, u, v; i<=m; i++){
cin>>u>>v;
G[v].push_back({u,i});
G[u].push_back({v,i});
out_e[i]=q+1;
}
for(int i=1, r; i<=q; i++){
cin>>r; out_e[r]=i;
}
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3064 KB |
Output is correct |
2 |
Correct |
5 ms |
3212 KB |
Output is correct |
3 |
Correct |
5 ms |
3340 KB |
Output is correct |
4 |
Correct |
5 ms |
3340 KB |
Output is correct |
5 |
Correct |
5 ms |
3340 KB |
Output is correct |
6 |
Correct |
5 ms |
3340 KB |
Output is correct |
7 |
Correct |
4 ms |
3340 KB |
Output is correct |
8 |
Correct |
5 ms |
3340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3064 KB |
Output is correct |
2 |
Correct |
5 ms |
3212 KB |
Output is correct |
3 |
Correct |
5 ms |
3340 KB |
Output is correct |
4 |
Correct |
5 ms |
3340 KB |
Output is correct |
5 |
Correct |
5 ms |
3340 KB |
Output is correct |
6 |
Correct |
5 ms |
3340 KB |
Output is correct |
7 |
Correct |
4 ms |
3340 KB |
Output is correct |
8 |
Correct |
5 ms |
3340 KB |
Output is correct |
9 |
Correct |
118 ms |
11108 KB |
Output is correct |
10 |
Correct |
154 ms |
11128 KB |
Output is correct |
11 |
Correct |
142 ms |
11128 KB |
Output is correct |
12 |
Correct |
108 ms |
11128 KB |
Output is correct |
13 |
Correct |
104 ms |
11128 KB |
Output is correct |
14 |
Correct |
107 ms |
11128 KB |
Output is correct |
15 |
Correct |
96 ms |
11128 KB |
Output is correct |
16 |
Correct |
58 ms |
11128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
11260 KB |
Output is correct |
2 |
Correct |
149 ms |
11316 KB |
Output is correct |
3 |
Correct |
78 ms |
11316 KB |
Output is correct |
4 |
Correct |
106 ms |
11316 KB |
Output is correct |
5 |
Correct |
135 ms |
11316 KB |
Output is correct |
6 |
Correct |
96 ms |
11316 KB |
Output is correct |
7 |
Correct |
86 ms |
11316 KB |
Output is correct |
8 |
Correct |
49 ms |
11316 KB |
Output is correct |
9 |
Correct |
35 ms |
11316 KB |
Output is correct |
10 |
Correct |
49 ms |
11316 KB |
Output is correct |
11 |
Correct |
169 ms |
11316 KB |
Output is correct |
12 |
Correct |
116 ms |
11316 KB |
Output is correct |
13 |
Correct |
107 ms |
11316 KB |
Output is correct |
14 |
Correct |
118 ms |
11316 KB |
Output is correct |
15 |
Correct |
121 ms |
11316 KB |
Output is correct |
16 |
Correct |
142 ms |
11316 KB |
Output is correct |
17 |
Runtime error |
159 ms |
18964 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
3064 KB |
Output is correct |
2 |
Correct |
5 ms |
3212 KB |
Output is correct |
3 |
Correct |
5 ms |
3340 KB |
Output is correct |
4 |
Correct |
5 ms |
3340 KB |
Output is correct |
5 |
Correct |
5 ms |
3340 KB |
Output is correct |
6 |
Correct |
5 ms |
3340 KB |
Output is correct |
7 |
Correct |
4 ms |
3340 KB |
Output is correct |
8 |
Correct |
5 ms |
3340 KB |
Output is correct |
9 |
Correct |
118 ms |
11108 KB |
Output is correct |
10 |
Correct |
154 ms |
11128 KB |
Output is correct |
11 |
Correct |
142 ms |
11128 KB |
Output is correct |
12 |
Correct |
108 ms |
11128 KB |
Output is correct |
13 |
Correct |
104 ms |
11128 KB |
Output is correct |
14 |
Correct |
107 ms |
11128 KB |
Output is correct |
15 |
Correct |
96 ms |
11128 KB |
Output is correct |
16 |
Correct |
58 ms |
11128 KB |
Output is correct |
17 |
Correct |
122 ms |
11260 KB |
Output is correct |
18 |
Correct |
149 ms |
11316 KB |
Output is correct |
19 |
Correct |
78 ms |
11316 KB |
Output is correct |
20 |
Correct |
106 ms |
11316 KB |
Output is correct |
21 |
Correct |
135 ms |
11316 KB |
Output is correct |
22 |
Correct |
96 ms |
11316 KB |
Output is correct |
23 |
Correct |
86 ms |
11316 KB |
Output is correct |
24 |
Correct |
49 ms |
11316 KB |
Output is correct |
25 |
Correct |
35 ms |
11316 KB |
Output is correct |
26 |
Correct |
49 ms |
11316 KB |
Output is correct |
27 |
Correct |
169 ms |
11316 KB |
Output is correct |
28 |
Correct |
116 ms |
11316 KB |
Output is correct |
29 |
Correct |
107 ms |
11316 KB |
Output is correct |
30 |
Correct |
118 ms |
11316 KB |
Output is correct |
31 |
Correct |
121 ms |
11316 KB |
Output is correct |
32 |
Correct |
142 ms |
11316 KB |
Output is correct |
33 |
Runtime error |
159 ms |
18964 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
34 |
Halted |
0 ms |
0 KB |
- |