Submission #51337

# Submission time Handle Problem Language Result Execution time Memory
51337 2018-06-17T13:52:32 Z Diuven None (JOI16_ho_t3) C++11
100 / 100
235 ms 12912 KB
#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[2*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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3560 KB Output is correct
3 Correct 6 ms 3752 KB Output is correct
4 Correct 5 ms 3808 KB Output is correct
5 Correct 5 ms 3808 KB Output is correct
6 Correct 5 ms 3808 KB Output is correct
7 Correct 4 ms 3808 KB Output is correct
8 Correct 6 ms 3808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3560 KB Output is correct
3 Correct 6 ms 3752 KB Output is correct
4 Correct 5 ms 3808 KB Output is correct
5 Correct 5 ms 3808 KB Output is correct
6 Correct 5 ms 3808 KB Output is correct
7 Correct 4 ms 3808 KB Output is correct
8 Correct 6 ms 3808 KB Output is correct
9 Correct 167 ms 11724 KB Output is correct
10 Correct 156 ms 11724 KB Output is correct
11 Correct 143 ms 11724 KB Output is correct
12 Correct 169 ms 11724 KB Output is correct
13 Correct 127 ms 11724 KB Output is correct
14 Correct 141 ms 11724 KB Output is correct
15 Correct 63 ms 11724 KB Output is correct
16 Correct 55 ms 11724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 11724 KB Output is correct
2 Correct 124 ms 11724 KB Output is correct
3 Correct 84 ms 11724 KB Output is correct
4 Correct 119 ms 11724 KB Output is correct
5 Correct 116 ms 11724 KB Output is correct
6 Correct 121 ms 11724 KB Output is correct
7 Correct 74 ms 11724 KB Output is correct
8 Correct 65 ms 11724 KB Output is correct
9 Correct 56 ms 11724 KB Output is correct
10 Correct 41 ms 11724 KB Output is correct
11 Correct 160 ms 11724 KB Output is correct
12 Correct 128 ms 11724 KB Output is correct
13 Correct 133 ms 11724 KB Output is correct
14 Correct 147 ms 11724 KB Output is correct
15 Correct 132 ms 11724 KB Output is correct
16 Correct 128 ms 11724 KB Output is correct
17 Correct 162 ms 11724 KB Output is correct
18 Correct 110 ms 11724 KB Output is correct
19 Correct 182 ms 12588 KB Output is correct
20 Correct 177 ms 12588 KB Output is correct
21 Correct 92 ms 12588 KB Output is correct
22 Correct 75 ms 12588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3560 KB Output is correct
3 Correct 6 ms 3752 KB Output is correct
4 Correct 5 ms 3808 KB Output is correct
5 Correct 5 ms 3808 KB Output is correct
6 Correct 5 ms 3808 KB Output is correct
7 Correct 4 ms 3808 KB Output is correct
8 Correct 6 ms 3808 KB Output is correct
9 Correct 167 ms 11724 KB Output is correct
10 Correct 156 ms 11724 KB Output is correct
11 Correct 143 ms 11724 KB Output is correct
12 Correct 169 ms 11724 KB Output is correct
13 Correct 127 ms 11724 KB Output is correct
14 Correct 141 ms 11724 KB Output is correct
15 Correct 63 ms 11724 KB Output is correct
16 Correct 55 ms 11724 KB Output is correct
17 Correct 129 ms 11724 KB Output is correct
18 Correct 124 ms 11724 KB Output is correct
19 Correct 84 ms 11724 KB Output is correct
20 Correct 119 ms 11724 KB Output is correct
21 Correct 116 ms 11724 KB Output is correct
22 Correct 121 ms 11724 KB Output is correct
23 Correct 74 ms 11724 KB Output is correct
24 Correct 65 ms 11724 KB Output is correct
25 Correct 56 ms 11724 KB Output is correct
26 Correct 41 ms 11724 KB Output is correct
27 Correct 160 ms 11724 KB Output is correct
28 Correct 128 ms 11724 KB Output is correct
29 Correct 133 ms 11724 KB Output is correct
30 Correct 147 ms 11724 KB Output is correct
31 Correct 132 ms 11724 KB Output is correct
32 Correct 128 ms 11724 KB Output is correct
33 Correct 162 ms 11724 KB Output is correct
34 Correct 110 ms 11724 KB Output is correct
35 Correct 182 ms 12588 KB Output is correct
36 Correct 177 ms 12588 KB Output is correct
37 Correct 92 ms 12588 KB Output is correct
38 Correct 75 ms 12588 KB Output is correct
39 Correct 198 ms 12912 KB Output is correct
40 Correct 235 ms 12912 KB Output is correct
41 Correct 121 ms 12912 KB Output is correct
42 Correct 162 ms 12912 KB Output is correct
43 Correct 167 ms 12912 KB Output is correct
44 Correct 160 ms 12912 KB Output is correct
45 Correct 166 ms 12912 KB Output is correct
46 Correct 82 ms 12912 KB Output is correct
47 Correct 77 ms 12912 KB Output is correct
48 Correct 98 ms 12912 KB Output is correct
49 Correct 72 ms 12912 KB Output is correct
50 Correct 55 ms 12912 KB Output is correct
51 Correct 58 ms 12912 KB Output is correct
52 Correct 60 ms 12912 KB Output is correct
53 Correct 57 ms 12912 KB Output is correct
54 Correct 105 ms 12912 KB Output is correct