This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+4;
int n,m,q,k;
vector<int> adj[N];
queue<int> d;
int dis[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> q >> k;
for (int i=1; i<=n; i++) dis[i] = -1;
for (int a; q; q--){ cin >> a;
dis[a] = 0; d.push(a);
}
for (int a,b; m; m--){ cin >> a >> b;
adj[a].push_back(b), adj[b].push_back(a);
}
for (int u; d.size(); d.pop()){ u = d.front();
for (int v : adj[u]) if (dis[v] == -1){
dis[v] = dis[u]+1; d.push(v);
}
}
for (int i=1,l,r; i<=n; i++){ l = 0, r = n;
while (l < r){ int m = (l+r)>>1;
if (1ll*m*(m+1)/2*k < dis[i]) l = m+1;
else r = m;
}
cout << l << " ";
}
cout << "\n";
return 0;
}
# | 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... |