Submission #960522

# Submission time Handle Problem Language Result Execution time Memory
960522 2024-04-10T15:08:07 Z thinknoexit Security Guard (JOI23_guard) C++17
37 / 100
135 ms 21564 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 200200;
int a[N];
struct A {
    int v;
    ll w;
    bool operator < (const A& o) const {
        return w > o.w;
    }
};
priority_queue<A> pq;
int p[N];
ll dis[N];
bool vis[N];
vector<int> adj[N];
ll ans = 0;
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
    }
    while (m--) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    int idx = max_element(a + 1, a + 1 + n) - a;
    memset(dis, 0x3f, sizeof dis);
    dis[idx] = 0;
    pq.push({ idx, 0 });
    while (!pq.empty()) {
        auto x = pq.top();
        pq.pop();
        int v = x.v;
        if (dis[v] < x.w) continue;
        for (auto& x : adj[v]) {
            if (dis[x] > dis[v] + a[v]) {
                p[x] = v;
                dis[x] = dis[v] + a[v];
                pq.push({ x, dis[x] });
            }
        }
    }
    for (int i = 1;i <= n;i++) {
        ans += a[p[i]];
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 52 ms 14644 KB Output is correct
3 Correct 52 ms 14676 KB Output is correct
4 Correct 55 ms 14676 KB Output is correct
5 Correct 59 ms 14924 KB Output is correct
6 Correct 52 ms 14676 KB Output is correct
7 Correct 52 ms 14672 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 52 ms 14644 KB Output is correct
3 Correct 52 ms 14676 KB Output is correct
4 Correct 55 ms 14676 KB Output is correct
5 Correct 59 ms 14924 KB Output is correct
6 Correct 52 ms 14676 KB Output is correct
7 Correct 52 ms 14672 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6744 KB Output is correct
10 Correct 66 ms 14640 KB Output is correct
11 Correct 60 ms 14676 KB Output is correct
12 Correct 58 ms 14676 KB Output is correct
13 Correct 60 ms 14696 KB Output is correct
14 Correct 60 ms 14704 KB Output is correct
15 Correct 69 ms 14488 KB Output is correct
16 Correct 64 ms 14772 KB Output is correct
17 Correct 60 ms 14548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 52 ms 14644 KB Output is correct
3 Correct 52 ms 14676 KB Output is correct
4 Correct 55 ms 14676 KB Output is correct
5 Correct 59 ms 14924 KB Output is correct
6 Correct 52 ms 14676 KB Output is correct
7 Correct 52 ms 14672 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6744 KB Output is correct
10 Correct 66 ms 14640 KB Output is correct
11 Correct 60 ms 14676 KB Output is correct
12 Correct 58 ms 14676 KB Output is correct
13 Correct 60 ms 14696 KB Output is correct
14 Correct 60 ms 14704 KB Output is correct
15 Correct 69 ms 14488 KB Output is correct
16 Correct 64 ms 14772 KB Output is correct
17 Correct 60 ms 14548 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 86 ms 14636 KB Output is correct
20 Correct 87 ms 14644 KB Output is correct
21 Correct 135 ms 14800 KB Output is correct
22 Correct 104 ms 15572 KB Output is correct
23 Correct 87 ms 15700 KB Output is correct
24 Correct 111 ms 16224 KB Output is correct
25 Correct 100 ms 17856 KB Output is correct
26 Correct 82 ms 21180 KB Output is correct
27 Correct 93 ms 19940 KB Output is correct
28 Correct 102 ms 15500 KB Output is correct
29 Correct 97 ms 16076 KB Output is correct
30 Correct 85 ms 17516 KB Output is correct
31 Correct 79 ms 21564 KB Output is correct
32 Correct 107 ms 20544 KB Output is correct
33 Correct 113 ms 16896 KB Output is correct
34 Correct 115 ms 15896 KB Output is correct
35 Correct 105 ms 17856 KB Output is correct
36 Correct 115 ms 17908 KB Output is correct
37 Correct 103 ms 17960 KB Output is correct
38 Correct 92 ms 15936 KB Output is correct
39 Correct 87 ms 17220 KB Output is correct
40 Correct 85 ms 16184 KB Output is correct
41 Correct 85 ms 14592 KB Output is correct
42 Correct 104 ms 14672 KB Output is correct
43 Correct 103 ms 15500 KB Output is correct
44 Correct 115 ms 15576 KB Output is correct
45 Correct 103 ms 15592 KB Output is correct
46 Correct 114 ms 15572 KB Output is correct
47 Correct 112 ms 15572 KB Output is correct
48 Correct 113 ms 15420 KB Output is correct
49 Correct 113 ms 15572 KB Output is correct
50 Correct 120 ms 15576 KB Output is correct
51 Correct 110 ms 15576 KB Output is correct
52 Correct 108 ms 15580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 52 ms 14644 KB Output is correct
3 Correct 52 ms 14676 KB Output is correct
4 Correct 55 ms 14676 KB Output is correct
5 Correct 59 ms 14924 KB Output is correct
6 Correct 52 ms 14676 KB Output is correct
7 Correct 52 ms 14672 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6744 KB Output is correct
10 Correct 66 ms 14640 KB Output is correct
11 Correct 60 ms 14676 KB Output is correct
12 Correct 58 ms 14676 KB Output is correct
13 Correct 60 ms 14696 KB Output is correct
14 Correct 60 ms 14704 KB Output is correct
15 Correct 69 ms 14488 KB Output is correct
16 Correct 64 ms 14772 KB Output is correct
17 Correct 60 ms 14548 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 86 ms 14636 KB Output is correct
20 Correct 87 ms 14644 KB Output is correct
21 Correct 135 ms 14800 KB Output is correct
22 Correct 104 ms 15572 KB Output is correct
23 Correct 87 ms 15700 KB Output is correct
24 Correct 111 ms 16224 KB Output is correct
25 Correct 100 ms 17856 KB Output is correct
26 Correct 82 ms 21180 KB Output is correct
27 Correct 93 ms 19940 KB Output is correct
28 Correct 102 ms 15500 KB Output is correct
29 Correct 97 ms 16076 KB Output is correct
30 Correct 85 ms 17516 KB Output is correct
31 Correct 79 ms 21564 KB Output is correct
32 Correct 107 ms 20544 KB Output is correct
33 Correct 113 ms 16896 KB Output is correct
34 Correct 115 ms 15896 KB Output is correct
35 Correct 105 ms 17856 KB Output is correct
36 Correct 115 ms 17908 KB Output is correct
37 Correct 103 ms 17960 KB Output is correct
38 Correct 92 ms 15936 KB Output is correct
39 Correct 87 ms 17220 KB Output is correct
40 Correct 85 ms 16184 KB Output is correct
41 Correct 85 ms 14592 KB Output is correct
42 Correct 104 ms 14672 KB Output is correct
43 Correct 103 ms 15500 KB Output is correct
44 Correct 115 ms 15576 KB Output is correct
45 Correct 103 ms 15592 KB Output is correct
46 Correct 114 ms 15572 KB Output is correct
47 Correct 112 ms 15572 KB Output is correct
48 Correct 113 ms 15420 KB Output is correct
49 Correct 113 ms 15572 KB Output is correct
50 Correct 120 ms 15576 KB Output is correct
51 Correct 110 ms 15576 KB Output is correct
52 Correct 108 ms 15580 KB Output is correct
53 Correct 2 ms 6748 KB Output is correct
54 Incorrect 106 ms 14932 KB Output isn't correct
55 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Incorrect 2 ms 6744 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6744 KB Output is correct
2 Incorrect 2 ms 6744 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 6748 KB Output is correct
2 Correct 52 ms 14644 KB Output is correct
3 Correct 52 ms 14676 KB Output is correct
4 Correct 55 ms 14676 KB Output is correct
5 Correct 59 ms 14924 KB Output is correct
6 Correct 52 ms 14676 KB Output is correct
7 Correct 52 ms 14672 KB Output is correct
8 Correct 1 ms 6748 KB Output is correct
9 Correct 1 ms 6744 KB Output is correct
10 Correct 66 ms 14640 KB Output is correct
11 Correct 60 ms 14676 KB Output is correct
12 Correct 58 ms 14676 KB Output is correct
13 Correct 60 ms 14696 KB Output is correct
14 Correct 60 ms 14704 KB Output is correct
15 Correct 69 ms 14488 KB Output is correct
16 Correct 64 ms 14772 KB Output is correct
17 Correct 60 ms 14548 KB Output is correct
18 Correct 2 ms 6748 KB Output is correct
19 Correct 86 ms 14636 KB Output is correct
20 Correct 87 ms 14644 KB Output is correct
21 Correct 135 ms 14800 KB Output is correct
22 Correct 104 ms 15572 KB Output is correct
23 Correct 87 ms 15700 KB Output is correct
24 Correct 111 ms 16224 KB Output is correct
25 Correct 100 ms 17856 KB Output is correct
26 Correct 82 ms 21180 KB Output is correct
27 Correct 93 ms 19940 KB Output is correct
28 Correct 102 ms 15500 KB Output is correct
29 Correct 97 ms 16076 KB Output is correct
30 Correct 85 ms 17516 KB Output is correct
31 Correct 79 ms 21564 KB Output is correct
32 Correct 107 ms 20544 KB Output is correct
33 Correct 113 ms 16896 KB Output is correct
34 Correct 115 ms 15896 KB Output is correct
35 Correct 105 ms 17856 KB Output is correct
36 Correct 115 ms 17908 KB Output is correct
37 Correct 103 ms 17960 KB Output is correct
38 Correct 92 ms 15936 KB Output is correct
39 Correct 87 ms 17220 KB Output is correct
40 Correct 85 ms 16184 KB Output is correct
41 Correct 85 ms 14592 KB Output is correct
42 Correct 104 ms 14672 KB Output is correct
43 Correct 103 ms 15500 KB Output is correct
44 Correct 115 ms 15576 KB Output is correct
45 Correct 103 ms 15592 KB Output is correct
46 Correct 114 ms 15572 KB Output is correct
47 Correct 112 ms 15572 KB Output is correct
48 Correct 113 ms 15420 KB Output is correct
49 Correct 113 ms 15572 KB Output is correct
50 Correct 120 ms 15576 KB Output is correct
51 Correct 110 ms 15576 KB Output is correct
52 Correct 108 ms 15580 KB Output is correct
53 Correct 2 ms 6748 KB Output is correct
54 Incorrect 106 ms 14932 KB Output isn't correct
55 Halted 0 ms 0 KB -