#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){
int ans=sqrt((dp[v]*2)/k);
while(ans*(ans+1)*k<2*dp[v]) ans++;
while((ans-1)*ans*k>=2*dp[v]) ans--;
print(max(0,ans),"");
}
print('\n');
}
int main(){
_3qplfh5;
int t=1;
// cin>>t;
rep(cs,t)
slv();
//
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
3 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 |
3 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 |
3 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 |
3 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 |
1 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 |
2 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 |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
107 ms |
8060 KB |
Output is correct |
2 |
Correct |
132 ms |
8352 KB |
Output is correct |
3 |
Execution timed out |
1094 ms |
8424 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
122 ms |
8432 KB |
Output is correct |
2 |
Correct |
107 ms |
8288 KB |
Output is correct |
3 |
Execution timed out |
1087 ms |
8240 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
8136 KB |
Output is correct |
2 |
Correct |
92 ms |
8508 KB |
Output is correct |
3 |
Execution timed out |
1086 ms |
8404 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
7844 KB |
Output is correct |
2 |
Correct |
87 ms |
8264 KB |
Output is correct |
3 |
Execution timed out |
1083 ms |
8304 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
97 ms |
7924 KB |
Output is correct |
2 |
Correct |
85 ms |
8116 KB |
Output is correct |
3 |
Execution timed out |
1025 ms |
8136 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
90 ms |
7912 KB |
Output is correct |
2 |
Correct |
79 ms |
8048 KB |
Output is correct |
3 |
Execution timed out |
1086 ms |
8000 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
139 ms |
7944 KB |
Output is correct |
2 |
Correct |
86 ms |
7872 KB |
Output is correct |
3 |
Execution timed out |
1086 ms |
8312 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |