#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 |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2668 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2644 KB |
Output is correct |
2 |
Correct |
3 ms |
2676 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
2 ms |
2644 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
94 ms |
9416 KB |
Output is correct |
2 |
Correct |
116 ms |
9772 KB |
Output is correct |
3 |
Correct |
120 ms |
10100 KB |
Output is correct |
4 |
Correct |
80 ms |
8780 KB |
Output is correct |
5 |
Correct |
99 ms |
9112 KB |
Output is correct |
6 |
Correct |
79 ms |
10104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
134 ms |
9844 KB |
Output is correct |
2 |
Correct |
96 ms |
9676 KB |
Output is correct |
3 |
Correct |
104 ms |
9848 KB |
Output is correct |
4 |
Correct |
120 ms |
9920 KB |
Output is correct |
5 |
Correct |
115 ms |
9620 KB |
Output is correct |
6 |
Correct |
83 ms |
9500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
9492 KB |
Output is correct |
2 |
Correct |
123 ms |
9872 KB |
Output is correct |
3 |
Correct |
137 ms |
10072 KB |
Output is correct |
4 |
Correct |
121 ms |
9904 KB |
Output is correct |
5 |
Correct |
102 ms |
9292 KB |
Output is correct |
6 |
Correct |
93 ms |
9592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
110 ms |
8964 KB |
Output is correct |
2 |
Correct |
121 ms |
9608 KB |
Output is correct |
3 |
Correct |
82 ms |
10052 KB |
Output is correct |
4 |
Correct |
77 ms |
9292 KB |
Output is correct |
5 |
Correct |
70 ms |
9036 KB |
Output is correct |
6 |
Correct |
74 ms |
9488 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
97 ms |
9096 KB |
Output is correct |
2 |
Correct |
76 ms |
9472 KB |
Output is correct |
3 |
Correct |
89 ms |
9352 KB |
Output is correct |
4 |
Correct |
90 ms |
9220 KB |
Output is correct |
5 |
Correct |
99 ms |
9344 KB |
Output is correct |
6 |
Correct |
65 ms |
9308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
88 ms |
9112 KB |
Output is correct |
2 |
Correct |
93 ms |
9420 KB |
Output is correct |
3 |
Correct |
94 ms |
9376 KB |
Output is correct |
4 |
Correct |
88 ms |
9584 KB |
Output is correct |
5 |
Correct |
105 ms |
9152 KB |
Output is correct |
6 |
Correct |
92 ms |
9560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
70 ms |
9236 KB |
Output is correct |
2 |
Correct |
62 ms |
8844 KB |
Output is correct |
3 |
Correct |
84 ms |
10028 KB |
Output is correct |
4 |
Correct |
86 ms |
9240 KB |
Output is correct |
5 |
Correct |
89 ms |
9420 KB |
Output is correct |
6 |
Correct |
128 ms |
10112 KB |
Output is correct |