#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//ideja je da nadjemo rastojanje
//svakog cvora od pocetnih
//i da onda vidimo koji im je lower_bound
//u nizu prefiksnih suma k,3k,6k...
//treba da se testira
int n,m,q;
ll k;
vector<int> adj[100005];
queue<int> qq;
ll dist[100005];
vector<ll> s;
void rasiri()
{
while(!qq.empty())
{
int cv = qq.front();
qq.pop();
for(int x : adj[cv])
{
if(dist[x]==-1)
{
dist[x] = dist[cv]+1;
qq.push(x);
}
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cerr.tie(0);
cin >> n >> m >> q >> k;
for(int i=1;i<=n;i++)
dist[i] = -1;
for(ll i = k;i<=n;i+=k)
{
if(i==k) s.push_back(k);
else
{
s.push_back(s.back() + i);
}
}
for(int i=1;i<=q;i++)
{
int x;
cin >> x;
qq.push(x);
dist[x] = 0;
}
for(int i=1;i<=m;i++)
{
int u,v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
rasiri();
for(int i=1;i<=n;i++)
{
if(dist[i]==0)
{
cout << 0 << " ";
continue;
}
vector<ll>::iterator it;
it = lower_bound(s.begin(),s.end(),dist[i]);
int dani = it-s.begin()+1;
cout << dani << " ";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
8 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2560 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
6 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
2688 KB |
Output is correct |
2 |
Correct |
6 ms |
2688 KB |
Output is correct |
3 |
Correct |
8 ms |
2688 KB |
Output is correct |
4 |
Correct |
6 ms |
2688 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
9980 KB |
Output is correct |
2 |
Correct |
100 ms |
11120 KB |
Output is correct |
3 |
Correct |
110 ms |
11500 KB |
Output is correct |
4 |
Correct |
97 ms |
9592 KB |
Output is correct |
5 |
Correct |
85 ms |
9592 KB |
Output is correct |
6 |
Correct |
103 ms |
10744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
104 ms |
10488 KB |
Output is correct |
2 |
Correct |
112 ms |
11044 KB |
Output is correct |
3 |
Correct |
98 ms |
11116 KB |
Output is correct |
4 |
Correct |
101 ms |
10616 KB |
Output is correct |
5 |
Correct |
94 ms |
10104 KB |
Output is correct |
6 |
Correct |
88 ms |
10132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
10104 KB |
Output is correct |
2 |
Correct |
101 ms |
11248 KB |
Output is correct |
3 |
Correct |
110 ms |
11500 KB |
Output is correct |
4 |
Correct |
98 ms |
10616 KB |
Output is correct |
5 |
Correct |
84 ms |
9720 KB |
Output is correct |
6 |
Correct |
90 ms |
10104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
83 ms |
9720 KB |
Output is correct |
2 |
Correct |
94 ms |
10864 KB |
Output is correct |
3 |
Correct |
100 ms |
11248 KB |
Output is correct |
4 |
Correct |
96 ms |
9976 KB |
Output is correct |
5 |
Correct |
80 ms |
9464 KB |
Output is correct |
6 |
Correct |
86 ms |
10352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
91 ms |
9716 KB |
Output is correct |
2 |
Correct |
92 ms |
10736 KB |
Output is correct |
3 |
Correct |
88 ms |
10736 KB |
Output is correct |
4 |
Correct |
90 ms |
10100 KB |
Output is correct |
5 |
Correct |
90 ms |
9848 KB |
Output is correct |
6 |
Correct |
86 ms |
10104 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
87 ms |
9720 KB |
Output is correct |
2 |
Correct |
106 ms |
10896 KB |
Output is correct |
3 |
Correct |
87 ms |
10604 KB |
Output is correct |
4 |
Correct |
91 ms |
10232 KB |
Output is correct |
5 |
Correct |
84 ms |
9720 KB |
Output is correct |
6 |
Correct |
87 ms |
10352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
89 ms |
9848 KB |
Output is correct |
2 |
Correct |
84 ms |
10224 KB |
Output is correct |
3 |
Correct |
103 ms |
11372 KB |
Output is correct |
4 |
Correct |
91 ms |
9840 KB |
Output is correct |
5 |
Correct |
96 ms |
9976 KB |
Output is correct |
6 |
Correct |
99 ms |
10744 KB |
Output is correct |