# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
998983 | vjudge1 | Birmingham (COCI20_birmingham) | C++17 | 101 ms | 8276 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 M = 1e5 + 1;
vector<int> nei[M];
int dis[M];
bool vis[M];
void bfs(vector<int> v)
{
for (int i=0;i<M;i++)
dis[i]=M;
queue<int> q;
for (int i:v)
dis[i]=0,q.push(i);
while (!q.empty())
{
int u=q.front();
q.pop();
for (int i:nei[u])
if (!vis[i] && dis[i]>dis[u]+1)
{
vis[i]=true;
dis[i]=dis[u]+1;
q.push(i);
}
}
}
int wtf(int d)
{
for (int i=0;i<=d;i++)
if (i*(i+1)/2>=d)
return i;
}
int main()
{
int n,m,q,k;
cin>>n>>m>>q>>k;
vector<int> v(q);
for (int i=0;i<q;i++)
cin>>v[i];
for (int i=0;i<m;i++)
{
int u,v;
cin>>u>>v;
nei[u].push_back(v);
nei[v].push_back(u);
}
bfs(v);
for (int i=1;i<=n;i++)
{
int d=(dis[i]+k-1)/k;
cout<<wtf(d)<<' ';
}
cout<<endl;
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... |