# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
340394 | Hazem | Birmingham (COCI20_birmingham) | C++14 | 176 ms | 13932 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
ID: tmhazem1
LANG: C++14
TASK: pprime
*/
#include <bits/stdc++.h>
using namespace std;
#define S second
#define F first
#define LL long long
const int N = 2e5 + 10;
LL LINF = 100000000000000000;
LL INF = 1000000000;
int MOD = 1e9+7;
vector<int>adj[N];
queue<int>que;
int dis[N],vis[N];
void bfs(){
while(!que.empty()){
int u = que.front();
que.pop();
if(vis[u])continue;
vis[u] = 1;
for(auto x:adj[u])
dis[x] = min(dis[x],dis[u]+1),que.push(x);
}
}
int main()
{
//freopen("out.txt","w",stdout);
int n,m,k,q;
scanf("%d%d%d%d",&n,&m,&q,&k);
for(int i=1;i<=n;i++)
dis[i] = INF;
for(int i=1;i<=q;i++){
int x;cin>>x;
dis[x] = 0;
que.push(x);
}
for(int i=1;i<=m;i++){
int u,v;
scanf("%d%d",&u,&v);
adj[u].push_back(v);
adj[v].push_back(u);
}
bfs();
for(int i=1;i<=n;i++){
int cur = 0;
for(int j=0;;j++)
if(cur>=dis[i]){
printf("%d ",j);
break;
}
else cur += k*(j+1);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |