# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238448 | vankata | Birmingham (COCI20_birmingham) | C++14 | 300 ms | 11888 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;
const int MAXN = (int )(1<<17);
vector<long long >v[MAXN];
vector <long long > rig;
long long n,m,q,k,used[MAXN];
void BFS()
{
long long i,j;
queue<long long >q;
for(auto nb:rig)
{
used[nb]=true;
q.push(nb);
}
while(!q.empty())
{
i=q.front();
q.pop();
for(auto nb:v[i])
{
if(!used[nb])
{
used[nb]=used[i]+1;
q.push(nb);
}
}
}
}
void read()
{
long long i,j,x,y;
cin>>n>>m>>q>>k;
for(i=0;i<q;i++)
{
cin>>x;
rig.push_back(x);
}
for(i=0;i<m;i++)
{
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
}
void solve()
{
long long i,ans=0;
for(i=1;i<=n;i++)
{
used[i]--;
ans = ceil((-1+sqrt(1+4*used[i]*2/k))/2);
cout<<ans<<" ";
}cout<<endl;
}
int main()
{
read();
BFS();
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... |