This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// clang-format off
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define ll long long
#define lg2(x) (63 - __builtin_clzll(x))
#define db cerr << "BREAK\n"
#define fp(...) fprintf(stderr, __VA_ARGS__)
#define rs(a) a.resize(n)
#define hizli cin.tie(0);ios_base::sync_with_stdio(0)
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(a, b) for (int a = 0; a < b; a++)
#define af(x) for(auto&a:x)fp("%d ",a);fp("\n")
#define ff first
#define ss second
#define job main
// clang-format on
template <typename... Args> void in(Args &&...args) {
(std::cin >> ... >> args);
}
const int N = 2e5 + 5, MOD = 1e9 + 7;
/*
~Y .5. J~ ~J .5. 5: 77 :5 5: ?! ^Y ~J .5. Y^ ~? .5..Y^ !? .
^J .5. ?! ^J .5. Y: !7 :P^^G~.J7 ^Y ~J .5. Y^ ~J .5..Y^ 7? .
^Y .5. ?! ~J .5. Y^.Y##&&&@@&&&&G55 ^J .5. J~ ~? .5. Y~ !J .
^Y .5. J! ~J .5. 5#&@@@&&&@&@@@@@@&J!J .5. J~ ~J .5. Y^ !J .
:Y 5: ?! :Y .5^5&@@@@&&&&&&&@@@@&@@&5 .5. J~ ~J .5. Y~ ~Y .
:5 5: ?! ^Y P&@&&&&&&&&&&&&&&&&&&&&&!.P. Y~ ^J .5. Y~ ~J..
.5. Y: 77 ^Y .B&&&&&&&&&&&&&&B5YYG&&&@&:5. J! ~Y .5. J~ ~J .
.5. Y^ 77 ^Y ?&&&&&&&&&&&B5J7!7??JP&&@@YY. ?! ~Y .5. Y~ ~Y .
.5 Y^ !7 ^Y J#BP5555B#G7~~~!!7?JY5B@@@P5: J! ~J .P. J~ ~J..
.5 5: 7? ^Y ~J?7!7?!!77!!!!7?J5P#@@BG! Y! !Y .P. J~ ~J .
.5 Y^ !J :5 .G&PYJ77!!~~!!~~!!?JY5PG&&P5~ Y7 ~Y .P. J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second;
bool operator<(const ben &other){
return first > other.first;
}
bool comp(ben &other){
return first > other.first;
}
};
int job() {
hizli;
int n, m, q, k;
in(n, m, q, k);
adj.resize(n);
priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
vector<int> vdepth(n), mark(n);
for (int i = 0; i < q; i++) {
int vip;
in(vip);
pq.push({0, vip-1});
mark[vip-1]=1;
}
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
u--, v--;
adj[u].pb(v);
adj[v].pb(u);
}
while (!pq.empty()) {
int depth = pq.top().ff, node = pq.top().ss;
pq.pop();
for (auto &a : adj[node]) {
if (!mark[a]) {
pq.push({depth + 1, a});
// cerr << node+1 << "dan" << a+1 << "ya";
vdepth[a]=depth+1;
mark[a] = 1;
}
}
}
vector<unsigned ll> ar;
for(int i=1;i<2000;i++){
ar.pb(k*i*(i+1)/2);
}
// for(auto&a:ar){cout << a << endl;}
for(int i=0;i<n;i++){
auto it = lower_bound(all(ar),ceil(vdepth[i]));
int ans = it-ar.begin()+1;
// if(*it == ceil(vdepth[i]))
// ans--;
if(vdepth[i]==0){
ans=0;
}
cout << ans << endl;
// cout << ceil(vdepth[i]) << " " << *it << endl;
}
}
# | 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... |