#ifdef t9unkubj #include"debug.cpp" //#include"template_no_debug.h" #else #define dbg(...) 199958 #endif #undef _GLIBCXX_DEBUG #pragma GCC optimize("O3") using namespace std; #include using ll=long long; using ull=unsigned long long; templateusing vc=vector; templateusing vvc=vc>; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++) #define DREP(i,n,m) for(ll i=(n);i>=(m);i--) #define drep(i,n) for(ll i=((n)-1);i>=0;i--) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() template bool chmin(T &x, F y){ if(x>y){ x=y; return true; } return false; } template bool chmax(T &x, F y){ if(x>n>>m>>q; map,int>first; rep(i,m){ int a,b; cin>>a>>b; --a,--b; first[{a,b}]=1e9; } rep(i,q){ int c,d; cin>>c>>d; --c,--d; first[{c,d}]=i; } vvc>g(n); for(auto&[x,y]:first){ g[x.first].push_back({x.second,y}); g[x.second].push_back({x.first,y}); } vcmd(n,-1e9); md[0]=1e9; priority_queue>que; que.push({md[0],0}); while(que.size()){ auto [p,q]=que.top();que.pop(); if(md[q]!=p)continue; for(auto&[x,y]:g[q]){ if(chmax(md[x],min(p,y))){ que.push({md[x],x}); } } } REP(i,1,n){ if(md[i]>=q)cout<<"-1\n"; else if(md[i]<0)cout<<"0\n"; else cout<sync_with_stdio(0); pass_time=clock(); int t=1; //cin>>t; while(t--)solve(); pass_time=clock()-pass_time; dbg(pass_time/CLOCKS_PER_SEC); }