# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
238449 | vankata | Birmingham (COCI20_birmingham) | C++14 | 250 ms | 12040 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= used[i]/k;
if(used[i]%k)ans++;
ans*=2;
used[i]=sqrt(ans);
if(used[i]*(used[i]+1)<ans)used[i]++;
cout<<used[i]<<" ";
}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... |