# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
771408 |
2023-07-03T00:13:29 Z |
gggkik |
None (JOI16_ho_t3) |
C++14 |
|
117 ms |
31256 KB |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5+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 |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2680 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2680 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
108 ms |
24472 KB |
Output is correct |
10 |
Correct |
99 ms |
24428 KB |
Output is correct |
11 |
Correct |
83 ms |
22764 KB |
Output is correct |
12 |
Correct |
79 ms |
22808 KB |
Output is correct |
13 |
Correct |
88 ms |
23020 KB |
Output is correct |
14 |
Correct |
81 ms |
23076 KB |
Output is correct |
15 |
Correct |
42 ms |
15040 KB |
Output is correct |
16 |
Correct |
42 ms |
13264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
24448 KB |
Output is correct |
2 |
Correct |
100 ms |
24460 KB |
Output is correct |
3 |
Correct |
85 ms |
20680 KB |
Output is correct |
4 |
Correct |
82 ms |
22764 KB |
Output is correct |
5 |
Correct |
80 ms |
23020 KB |
Output is correct |
6 |
Correct |
75 ms |
23028 KB |
Output is correct |
7 |
Correct |
36 ms |
13284 KB |
Output is correct |
8 |
Correct |
35 ms |
13096 KB |
Output is correct |
9 |
Correct |
47 ms |
13432 KB |
Output is correct |
10 |
Correct |
43 ms |
14392 KB |
Output is correct |
11 |
Correct |
117 ms |
22788 KB |
Output is correct |
12 |
Correct |
92 ms |
21908 KB |
Output is correct |
13 |
Correct |
91 ms |
21484 KB |
Output is correct |
14 |
Correct |
116 ms |
23276 KB |
Output is correct |
15 |
Correct |
93 ms |
22024 KB |
Output is correct |
16 |
Correct |
98 ms |
21332 KB |
Output is correct |
17 |
Runtime error |
106 ms |
31256 KB |
Execution killed with signal 6 |
18 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2680 KB |
Output is correct |
3 |
Correct |
3 ms |
3028 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2772 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
1 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
108 ms |
24472 KB |
Output is correct |
10 |
Correct |
99 ms |
24428 KB |
Output is correct |
11 |
Correct |
83 ms |
22764 KB |
Output is correct |
12 |
Correct |
79 ms |
22808 KB |
Output is correct |
13 |
Correct |
88 ms |
23020 KB |
Output is correct |
14 |
Correct |
81 ms |
23076 KB |
Output is correct |
15 |
Correct |
42 ms |
15040 KB |
Output is correct |
16 |
Correct |
42 ms |
13264 KB |
Output is correct |
17 |
Correct |
95 ms |
24448 KB |
Output is correct |
18 |
Correct |
100 ms |
24460 KB |
Output is correct |
19 |
Correct |
85 ms |
20680 KB |
Output is correct |
20 |
Correct |
82 ms |
22764 KB |
Output is correct |
21 |
Correct |
80 ms |
23020 KB |
Output is correct |
22 |
Correct |
75 ms |
23028 KB |
Output is correct |
23 |
Correct |
36 ms |
13284 KB |
Output is correct |
24 |
Correct |
35 ms |
13096 KB |
Output is correct |
25 |
Correct |
47 ms |
13432 KB |
Output is correct |
26 |
Correct |
43 ms |
14392 KB |
Output is correct |
27 |
Correct |
117 ms |
22788 KB |
Output is correct |
28 |
Correct |
92 ms |
21908 KB |
Output is correct |
29 |
Correct |
91 ms |
21484 KB |
Output is correct |
30 |
Correct |
116 ms |
23276 KB |
Output is correct |
31 |
Correct |
93 ms |
22024 KB |
Output is correct |
32 |
Correct |
98 ms |
21332 KB |
Output is correct |
33 |
Runtime error |
106 ms |
31256 KB |
Execution killed with signal 6 |
34 |
Halted |
0 ms |
0 KB |
- |