# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
771410 |
2023-07-03T00:14:01 Z |
gggkik |
None (JOI16_ho_t3) |
C++14 |
|
145 ms |
29800 KB |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 2e5+5;
using pii = pair<int,int>;
pii d[MXN];
vector<pii> E[MXN];
int ans[MXN], n, m, q;
void dijkstra(int s){
priority_queue<pair<pii,int>> pq;
for(int i = 1;i<=n;i++) d[i] = {1<<30,1<<30};
d[s] = {0,q+1}; pq.push({{0,q+1},s});
for(;pq.size();){
int di = -pq.top().first.first, ci = pq.top().first.second, x = pq.top().second;
pq.pop();
if(d[x]!=pii{di,ci}) continue;
for(auto &i : E[x]) if(pii{d[i.first].first,-d[i.first].second}>pii{di+1,-min(ci,i.second)}){
d[i.first] = {di+1,min(ci,i.second)};
pq.push({{-di-1,min(ci,i.second)},i.first});
}
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
vector<vector<int>> edges;
for(int i = 0;i<m;i++){
int a,b; cin >> a >> b;
edges.push_back({a,b});
}
for(int i = 1;i<=q;i++){
int a; cin >> a;
edges[a-1].push_back(i);
}
for(auto &i : edges){
if(i.size()==2) i.push_back(q+1);
E[i[0]].push_back({i[1],i[2]});
E[i[1]].push_back({i[0],i[2]});
}
dijkstra(1);
for(int i = 1;i<=n;i++) {
ans[d[i].second]++;
}
for(int i = 1;i<=q;i++) {
ans[i] += ans[i-1];
cout << ans[i] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
5332 KB |
Output is correct |
4 |
Correct |
2 ms |
5012 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
2 ms |
5056 KB |
Output is correct |
7 |
Correct |
2 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
5332 KB |
Output is correct |
4 |
Correct |
2 ms |
5012 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
2 ms |
5056 KB |
Output is correct |
7 |
Correct |
2 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
9 |
Correct |
94 ms |
24480 KB |
Output is correct |
10 |
Correct |
99 ms |
24532 KB |
Output is correct |
11 |
Correct |
90 ms |
22748 KB |
Output is correct |
12 |
Correct |
88 ms |
22900 KB |
Output is correct |
13 |
Correct |
78 ms |
23052 KB |
Output is correct |
14 |
Correct |
99 ms |
23296 KB |
Output is correct |
15 |
Correct |
45 ms |
16024 KB |
Output is correct |
16 |
Correct |
38 ms |
14492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
103 ms |
24432 KB |
Output is correct |
2 |
Correct |
97 ms |
24508 KB |
Output is correct |
3 |
Correct |
83 ms |
21352 KB |
Output is correct |
4 |
Correct |
92 ms |
22892 KB |
Output is correct |
5 |
Correct |
85 ms |
23104 KB |
Output is correct |
6 |
Correct |
77 ms |
23152 KB |
Output is correct |
7 |
Correct |
41 ms |
14572 KB |
Output is correct |
8 |
Correct |
55 ms |
14320 KB |
Output is correct |
9 |
Correct |
46 ms |
14852 KB |
Output is correct |
10 |
Correct |
43 ms |
16160 KB |
Output is correct |
11 |
Correct |
122 ms |
22388 KB |
Output is correct |
12 |
Correct |
104 ms |
21868 KB |
Output is correct |
13 |
Correct |
94 ms |
21420 KB |
Output is correct |
14 |
Correct |
106 ms |
23056 KB |
Output is correct |
15 |
Correct |
97 ms |
21772 KB |
Output is correct |
16 |
Correct |
94 ms |
21276 KB |
Output is correct |
17 |
Correct |
128 ms |
20592 KB |
Output is correct |
18 |
Correct |
56 ms |
17144 KB |
Output is correct |
19 |
Correct |
135 ms |
28648 KB |
Output is correct |
20 |
Correct |
104 ms |
23256 KB |
Output is correct |
21 |
Correct |
49 ms |
16244 KB |
Output is correct |
22 |
Correct |
47 ms |
16144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4948 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
3 ms |
5332 KB |
Output is correct |
4 |
Correct |
2 ms |
5012 KB |
Output is correct |
5 |
Correct |
3 ms |
5076 KB |
Output is correct |
6 |
Correct |
2 ms |
5056 KB |
Output is correct |
7 |
Correct |
2 ms |
4948 KB |
Output is correct |
8 |
Correct |
2 ms |
4948 KB |
Output is correct |
9 |
Correct |
94 ms |
24480 KB |
Output is correct |
10 |
Correct |
99 ms |
24532 KB |
Output is correct |
11 |
Correct |
90 ms |
22748 KB |
Output is correct |
12 |
Correct |
88 ms |
22900 KB |
Output is correct |
13 |
Correct |
78 ms |
23052 KB |
Output is correct |
14 |
Correct |
99 ms |
23296 KB |
Output is correct |
15 |
Correct |
45 ms |
16024 KB |
Output is correct |
16 |
Correct |
38 ms |
14492 KB |
Output is correct |
17 |
Correct |
103 ms |
24432 KB |
Output is correct |
18 |
Correct |
97 ms |
24508 KB |
Output is correct |
19 |
Correct |
83 ms |
21352 KB |
Output is correct |
20 |
Correct |
92 ms |
22892 KB |
Output is correct |
21 |
Correct |
85 ms |
23104 KB |
Output is correct |
22 |
Correct |
77 ms |
23152 KB |
Output is correct |
23 |
Correct |
41 ms |
14572 KB |
Output is correct |
24 |
Correct |
55 ms |
14320 KB |
Output is correct |
25 |
Correct |
46 ms |
14852 KB |
Output is correct |
26 |
Correct |
43 ms |
16160 KB |
Output is correct |
27 |
Correct |
122 ms |
22388 KB |
Output is correct |
28 |
Correct |
104 ms |
21868 KB |
Output is correct |
29 |
Correct |
94 ms |
21420 KB |
Output is correct |
30 |
Correct |
106 ms |
23056 KB |
Output is correct |
31 |
Correct |
97 ms |
21772 KB |
Output is correct |
32 |
Correct |
94 ms |
21276 KB |
Output is correct |
33 |
Correct |
128 ms |
20592 KB |
Output is correct |
34 |
Correct |
56 ms |
17144 KB |
Output is correct |
35 |
Correct |
135 ms |
28648 KB |
Output is correct |
36 |
Correct |
104 ms |
23256 KB |
Output is correct |
37 |
Correct |
49 ms |
16244 KB |
Output is correct |
38 |
Correct |
47 ms |
16144 KB |
Output is correct |
39 |
Correct |
145 ms |
29704 KB |
Output is correct |
40 |
Correct |
143 ms |
29800 KB |
Output is correct |
41 |
Correct |
111 ms |
24668 KB |
Output is correct |
42 |
Correct |
138 ms |
28264 KB |
Output is correct |
43 |
Correct |
122 ms |
28324 KB |
Output is correct |
44 |
Correct |
130 ms |
28144 KB |
Output is correct |
45 |
Correct |
118 ms |
28068 KB |
Output is correct |
46 |
Correct |
57 ms |
18048 KB |
Output is correct |
47 |
Correct |
53 ms |
17232 KB |
Output is correct |
48 |
Correct |
53 ms |
17108 KB |
Output is correct |
49 |
Correct |
60 ms |
17000 KB |
Output is correct |
50 |
Correct |
59 ms |
17320 KB |
Output is correct |
51 |
Correct |
60 ms |
17916 KB |
Output is correct |
52 |
Correct |
59 ms |
18168 KB |
Output is correct |
53 |
Correct |
56 ms |
16852 KB |
Output is correct |
54 |
Correct |
64 ms |
17268 KB |
Output is correct |