이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fff "main"
#define For(i,a,b) for (auto i = a; i < b; ++i)
#define pb push_back
#define en cout << '\n';
using namespace std;
typedef signed long long int ll;
typedef std::vector<ll> vll;
vector<pair<ll,ll> > ct[100001];
ll d[100001];
ll know_first[100001];
ll n,m,q,k;
void spf(){
priority_queue<pair<ll, ll >, vector<pair<ll,ll > >, greater<pair<ll, ll > > >pq;
For (i,1,n+1) {
d[i] = 99999999999;
if (know_first[i]){
d[i] = 0;
pq.push({0,i});
}
}
while (pq.size()) {
ll u = pq.top().second;
ll du = pq.top().first;
pq.pop();
if (du > d[u]) continue;
for (auto f : ct[u]){
ll v = f.second;
ll w = f.first;
if (d[v] > du + w) {
d[v] = du + w;
pq.push({d[v], v});
}
}
}
}
ll sum_to(const ll &x){
return (x * (x + 1)) / 2;
}
int main()
{
// if (fopen(fff".inp","r")) {
// freopen(fff".inp","r",stdin);
// freopen(fff".out","w",stdout);
// }
ios_base :: sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m >> q >> k;
while (q--) {
ll f;
cin >> f;
know_first[f] = 1;
}
while (m--){
ll u, v; cin >> u >> v;
ct[u].pb({1,v});
ct[v].pb({1,u});
}
spf();
vll check;
for (ll i = 0; sum_to(i) <= n / k; ++i){
check.pb(sum_to(i) * k);
}
For (i,1,n+1){
cout << lower_bound(check.begin(),check.end(),d[i]) - check.begin() << ' ';
}
return 0;
}
# | 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... |