# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
995266 |
2024-06-08T17:50:59 Z |
gmroh06 |
None (JOI16_ho_t3) |
C++14 |
|
91 ms |
22868 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
inline void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
const ll INF = 1e18;
ll n, m, q;
int main() {
fastio();
cin >> n >> m >> q;
vector<vector<pll>> gr(n);
vector<ll> idx(m, q), ans(n, -1), dist(n, INF);
vector<ll> fin(q + 1, 0);
for (ll i = 0, a, b; i < m; i++) {
cin >> a >> b;
gr[a - 1].emplace_back(b - 1, i);
gr[b - 1].emplace_back(a - 1, i);
}
for (ll i = 0, k; i < q; i++) {
cin >> k;
idx[k - 1] = i;
}
ans[0] = q;
dist[0] = 0;
queue<ll> qu;
qu.emplace(0);
while (!qu.empty()) {
ll loc = qu.front();
qu.pop();
for (auto& [x, i] : gr[loc]) {
if (dist[x] > dist[loc] + 1) {
dist[x] = dist[loc] + 1;
qu.emplace(x);
}
if (dist[x] == dist[loc] + 1) {
ans[x] = max(ans[x], min(ans[loc], idx[i]));
}
}
}
for (auto& x : ans) {
fin[x]++;
}
for (ll i = 0, tmp = fin[0]; i < q; tmp += fin[++i]) {
cout << tmp << '\n';
}
return 0;
}
Compilation message
2016_ho_t3.cpp: In function 'int main()':
2016_ho_t3.cpp:49:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
49 | for (auto& [x, i] : gr[loc]) {
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
62 ms |
18772 KB |
Output is correct |
10 |
Correct |
78 ms |
18776 KB |
Output is correct |
11 |
Correct |
62 ms |
18260 KB |
Output is correct |
12 |
Correct |
59 ms |
18260 KB |
Output is correct |
13 |
Correct |
56 ms |
18376 KB |
Output is correct |
14 |
Correct |
57 ms |
18108 KB |
Output is correct |
15 |
Correct |
33 ms |
12604 KB |
Output is correct |
16 |
Correct |
30 ms |
11604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
18772 KB |
Output is correct |
2 |
Correct |
61 ms |
18916 KB |
Output is correct |
3 |
Correct |
45 ms |
15296 KB |
Output is correct |
4 |
Correct |
53 ms |
18004 KB |
Output is correct |
5 |
Correct |
59 ms |
18260 KB |
Output is correct |
6 |
Correct |
71 ms |
18260 KB |
Output is correct |
7 |
Correct |
33 ms |
11604 KB |
Output is correct |
8 |
Correct |
30 ms |
11356 KB |
Output is correct |
9 |
Correct |
22 ms |
9540 KB |
Output is correct |
10 |
Correct |
19 ms |
9676 KB |
Output is correct |
11 |
Correct |
61 ms |
18600 KB |
Output is correct |
12 |
Correct |
52 ms |
17748 KB |
Output is correct |
13 |
Correct |
56 ms |
17488 KB |
Output is correct |
14 |
Correct |
60 ms |
18696 KB |
Output is correct |
15 |
Correct |
66 ms |
18004 KB |
Output is correct |
16 |
Correct |
65 ms |
17320 KB |
Output is correct |
17 |
Correct |
76 ms |
18076 KB |
Output is correct |
18 |
Correct |
49 ms |
13652 KB |
Output is correct |
19 |
Correct |
82 ms |
22360 KB |
Output is correct |
20 |
Correct |
61 ms |
18260 KB |
Output is correct |
21 |
Correct |
39 ms |
12372 KB |
Output is correct |
22 |
Correct |
46 ms |
12116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
62 ms |
18772 KB |
Output is correct |
10 |
Correct |
78 ms |
18776 KB |
Output is correct |
11 |
Correct |
62 ms |
18260 KB |
Output is correct |
12 |
Correct |
59 ms |
18260 KB |
Output is correct |
13 |
Correct |
56 ms |
18376 KB |
Output is correct |
14 |
Correct |
57 ms |
18108 KB |
Output is correct |
15 |
Correct |
33 ms |
12604 KB |
Output is correct |
16 |
Correct |
30 ms |
11604 KB |
Output is correct |
17 |
Correct |
56 ms |
18772 KB |
Output is correct |
18 |
Correct |
61 ms |
18916 KB |
Output is correct |
19 |
Correct |
45 ms |
15296 KB |
Output is correct |
20 |
Correct |
53 ms |
18004 KB |
Output is correct |
21 |
Correct |
59 ms |
18260 KB |
Output is correct |
22 |
Correct |
71 ms |
18260 KB |
Output is correct |
23 |
Correct |
33 ms |
11604 KB |
Output is correct |
24 |
Correct |
30 ms |
11356 KB |
Output is correct |
25 |
Correct |
22 ms |
9540 KB |
Output is correct |
26 |
Correct |
19 ms |
9676 KB |
Output is correct |
27 |
Correct |
61 ms |
18600 KB |
Output is correct |
28 |
Correct |
52 ms |
17748 KB |
Output is correct |
29 |
Correct |
56 ms |
17488 KB |
Output is correct |
30 |
Correct |
60 ms |
18696 KB |
Output is correct |
31 |
Correct |
66 ms |
18004 KB |
Output is correct |
32 |
Correct |
65 ms |
17320 KB |
Output is correct |
33 |
Correct |
76 ms |
18076 KB |
Output is correct |
34 |
Correct |
49 ms |
13652 KB |
Output is correct |
35 |
Correct |
82 ms |
22360 KB |
Output is correct |
36 |
Correct |
61 ms |
18260 KB |
Output is correct |
37 |
Correct |
39 ms |
12372 KB |
Output is correct |
38 |
Correct |
46 ms |
12116 KB |
Output is correct |
39 |
Correct |
80 ms |
22868 KB |
Output is correct |
40 |
Correct |
83 ms |
22864 KB |
Output is correct |
41 |
Correct |
53 ms |
17348 KB |
Output is correct |
42 |
Correct |
75 ms |
22204 KB |
Output is correct |
43 |
Correct |
84 ms |
22228 KB |
Output is correct |
44 |
Correct |
76 ms |
22100 KB |
Output is correct |
45 |
Correct |
91 ms |
22108 KB |
Output is correct |
46 |
Correct |
48 ms |
14136 KB |
Output is correct |
47 |
Correct |
42 ms |
13652 KB |
Output is correct |
48 |
Correct |
48 ms |
13300 KB |
Output is correct |
49 |
Correct |
27 ms |
11324 KB |
Output is correct |
50 |
Correct |
28 ms |
11460 KB |
Output is correct |
51 |
Correct |
31 ms |
12100 KB |
Output is correct |
52 |
Correct |
30 ms |
12228 KB |
Output is correct |
53 |
Correct |
29 ms |
11076 KB |
Output is correct |
54 |
Correct |
27 ms |
11464 KB |
Output is correct |