# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1124227 | tuannm | Birmingham (COCI20_birmingham) | C++20 | 96 ms | 7876 KiB |
#include<bits/stdc++.h>
#define ii pair<int, int>
#define ll pair<long long, long long>
#define fi first
#define se second
#define pb push_back
using namespace std;
const int mod[2] = {1000000007, 998244353};
const int N = 1e5 + 1;
const string NAME = "rumor";
int n, m, q, k, d[N];
vector<int> adj[N];
queue<int> que;
void inp(){
cin >> n >> m >> q >> k;
for(int i = 1; i <= n; ++i)
d[i] = -1;
for(int i = 1; i <= q; ++i){
int u;
cin >> u;
d[u] = 0;
que.push(u);
}
for(int i = 1; i <= m; ++i){
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
}
void solve(){
while(!que.empty()){
int u = que.front();
que.pop();
for(int v : adj[u])
if(d[v] == -1)
d[v] = d[u] + 1, que.push(v);
}
for(int i = 1; i <= n; ++i){
if(!d[i]){
cout << "0 ";
continue;
}
int l = 1, r = n, ans = n;
while(l <= r){
int mid = l + r >> 1;
if(1LL * mid * (mid + 1) * k / 2 >= d[i])
ans = mid, r = mid - 1;
else
l = mid + 1;
}
cout << ans << " ";
}
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen((NAME + ".inp").c_str(), "r")){
freopen((NAME + ".inp").c_str(), "r", stdin);
freopen((NAME + ".out").c_str(), "w", stdout);
}
inp();
solve();
}
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... |