# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
845129 | vjudge1 | Birmingham (COCI20_birmingham) | C++14 | 245 ms | 13504 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.
#include <bits/stdc++.h>
using namespace std;
void solve(void){
int n,m,q,k;
cin >> n >> m >> q >> k;
vector<int> insider(q);
vector<vector<int>> komsu(n);
for(int i=0; i<q; i++)
cin >> insider[i];
for(int i=0; i<m; i++){
int a,b;
cin >> a >> b;
a--;
b--;
komsu[a].push_back(b);
komsu[b].push_back(a);
}
vector<int> uzaklik(n,-1);
priority_queue<pair<int,int>> pq;
for(int i=0; i<q; i++){
pq.push({0, insider[i]-1});
}
while(pq.size()){
int len = -pq.top().first;
int node = pq.top().second;
pq.pop();
if( uzaklik[node] != -1 )
continue;
uzaklik[node] = len;
for(int i=0; i<komsu[node].size(); i++){
pq.push({-len-1, komsu[node][i]});
}
}
for(int i=0; i<n; i++){
int len = ceil( ((double) uzaklik[i] )/ k );
cout << ceil( (-1 + sqrt(1+8*len))/2 ) << " ";
}
cout << "\n";
}
int main(){
int t=1;
// cin >> t;
while(t--)
solve();
return 0;
}
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... |