#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3qplfh5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
void print(){
cout<<"\n";
}
template<class te,class ...ti>
void print(const te&v, const ti&...nv) {
cout<<v;
if(sizeof...(nv)){
cout<<" ";
print(nv...);
}
}
using pii=pair<int,int>;
using vi=vector<int>;
using vll=vector<long long>;
const int inf=1e9;
void slv(){
int n,m,q,k;
cin>>n>>m>>q>>k;
vi rbe(n,0);
rep(_,q){
int x;
cin>>x;
x--;
rbe[x]=1;
}
vec(vi) adj(n);
rep(i,m){
int u,v;
cin>>u>>v;
u--,v--;
adj[u].pb(v);
adj[v].pb(u);
}
priority_queue<pii,vec(pii),greater<pii>> pq;
vi dp(n,inf);
rep(v,n){
if(rbe[v]){
pq.push({0,v});
dp[v]=0;
}
}
while(sz(pq)){
pii top=pq.top();
pq.pop();
int v=top.se,cost=top.fi;
if(dp[v]!=cost) continue;
for(auto u : adj[v]){
if(dp[u]>cost+1){
dp[u]=cost+1;
pq.push({cost+1,u});
}
}
}
rep(v,n){
ll ans=sqrt((dp[v]*2)/k);
while(ans*(ans+1)*(ll)k<2ll*(ll)dp[v]) ans++;
while((ans-1)*ans*(ll)k>=2ll*(ll)dp[v] and ans>0) ans--;
print(max(0ll,ans),"");
}
print('\n');
}
int main(){
_3qplfh5;
int t=1;
// cin>>t;
rep(cs,t)
slv();
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
77 ms |
8048 KB |
Output is correct |
2 |
Correct |
92 ms |
8324 KB |
Output is correct |
3 |
Correct |
94 ms |
8448 KB |
Output is correct |
4 |
Correct |
77 ms |
9588 KB |
Output is correct |
5 |
Correct |
69 ms |
9792 KB |
Output is correct |
6 |
Correct |
121 ms |
11168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
115 ms |
8476 KB |
Output is correct |
2 |
Correct |
86 ms |
8188 KB |
Output is correct |
3 |
Correct |
114 ms |
8292 KB |
Output is correct |
4 |
Correct |
89 ms |
10616 KB |
Output is correct |
5 |
Correct |
92 ms |
10428 KB |
Output is correct |
6 |
Correct |
73 ms |
10528 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
79 ms |
8132 KB |
Output is correct |
2 |
Correct |
80 ms |
8360 KB |
Output is correct |
3 |
Correct |
103 ms |
8408 KB |
Output is correct |
4 |
Correct |
98 ms |
10628 KB |
Output is correct |
5 |
Correct |
79 ms |
9936 KB |
Output is correct |
6 |
Correct |
110 ms |
10536 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
70 ms |
7940 KB |
Output is correct |
2 |
Correct |
83 ms |
8196 KB |
Output is correct |
3 |
Correct |
79 ms |
8336 KB |
Output is correct |
4 |
Correct |
83 ms |
10140 KB |
Output is correct |
5 |
Correct |
92 ms |
9668 KB |
Output is correct |
6 |
Correct |
74 ms |
10524 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
7936 KB |
Output is correct |
2 |
Correct |
93 ms |
8072 KB |
Output is correct |
3 |
Correct |
97 ms |
7980 KB |
Output is correct |
4 |
Correct |
77 ms |
8004 KB |
Output is correct |
5 |
Correct |
77 ms |
8044 KB |
Output is correct |
6 |
Correct |
70 ms |
8240 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
7872 KB |
Output is correct |
2 |
Correct |
89 ms |
8088 KB |
Output is correct |
3 |
Correct |
68 ms |
8032 KB |
Output is correct |
4 |
Correct |
124 ms |
10308 KB |
Output is correct |
5 |
Correct |
101 ms |
9828 KB |
Output is correct |
6 |
Correct |
78 ms |
10676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
102 ms |
8048 KB |
Output is correct |
2 |
Correct |
78 ms |
7872 KB |
Output is correct |
3 |
Correct |
81 ms |
8392 KB |
Output is correct |
4 |
Correct |
76 ms |
9932 KB |
Output is correct |
5 |
Correct |
88 ms |
10300 KB |
Output is correct |
6 |
Correct |
90 ms |
11176 KB |
Output is correct |