Submission #51337

#TimeUsernameProblemLanguageResultExecution timeMemory
51337Diuven철도 요금 (JOI16_ho_t3)C++11
100 / 100
235 ms12912 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...