Submission #1061246

# Submission time Handle Problem Language Result Execution time Memory
1061246 2024-08-16T07:28:30 Z thinknoexit Reconstruction Project (JOI22_reconstruction) C++17
7 / 100
5000 ms 6460 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
struct Edge {
    int u, v, w;
    bool operator < (const Edge& o) const {
        return w < o.w;
    }
} e[100100], e2[100100];
int p[505];
int fr(int i) {
    return p[i] == i ? i : p[i] = fr(p[i]);
}
int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for (int i = 1;i <= m;i++) {
        cin >> e[i].u >> e[i].v >> e[i].w;
    }
    sort(e + 1, e + 1 + m);
    int q;
    cin >> q;
    while (q--) {
        int x;
        cin >> x;
        for (int i = 1;i <= m;i++) {
            e2[i].u = e[i].u;
            e2[i].v = e[i].v;
            e2[i].w = abs(e[i].w - x);
        }
        for (int i = 1;i <= n;i++) p[i] = i;
        sort(e2 + 1, e2 + 1 + m);
        ll ans = 0;
        for (int i = 1;i <= m;i++) {
            int pu = fr(e2[i].u), pv = fr(e2[i].v);
            if (pu == pv) continue;
            ans += e2[i].w;
            p[pu] = pv;
        }
        cout << ans << '\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2560 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2560 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 53 ms 2636 KB Output is correct
21 Correct 50 ms 2608 KB Output is correct
22 Correct 57 ms 2652 KB Output is correct
23 Correct 50 ms 2648 KB Output is correct
24 Correct 52 ms 2768 KB Output is correct
25 Correct 51 ms 2768 KB Output is correct
26 Correct 60 ms 2768 KB Output is correct
27 Correct 60 ms 2792 KB Output is correct
28 Correct 45 ms 2792 KB Output is correct
29 Correct 34 ms 2772 KB Output is correct
30 Correct 59 ms 2628 KB Output is correct
31 Correct 72 ms 2636 KB Output is correct
32 Correct 60 ms 2772 KB Output is correct
33 Correct 62 ms 2648 KB Output is correct
34 Correct 32 ms 2816 KB Output is correct
35 Correct 95 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Execution timed out 5060 ms 2808 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2560 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Execution timed out 5088 ms 6460 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2560 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 53 ms 2636 KB Output is correct
21 Correct 50 ms 2608 KB Output is correct
22 Correct 57 ms 2652 KB Output is correct
23 Correct 50 ms 2648 KB Output is correct
24 Correct 52 ms 2768 KB Output is correct
25 Correct 51 ms 2768 KB Output is correct
26 Correct 60 ms 2768 KB Output is correct
27 Correct 60 ms 2792 KB Output is correct
28 Correct 45 ms 2792 KB Output is correct
29 Correct 34 ms 2772 KB Output is correct
30 Correct 59 ms 2628 KB Output is correct
31 Correct 72 ms 2636 KB Output is correct
32 Correct 60 ms 2772 KB Output is correct
33 Correct 62 ms 2648 KB Output is correct
34 Correct 32 ms 2816 KB Output is correct
35 Correct 95 ms 2652 KB Output is correct
36 Execution timed out 5014 ms 2808 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2508 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 0 ms 2404 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2560 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 0 ms 2392 KB Output is correct
20 Correct 53 ms 2636 KB Output is correct
21 Correct 50 ms 2608 KB Output is correct
22 Correct 57 ms 2652 KB Output is correct
23 Correct 50 ms 2648 KB Output is correct
24 Correct 52 ms 2768 KB Output is correct
25 Correct 51 ms 2768 KB Output is correct
26 Correct 60 ms 2768 KB Output is correct
27 Correct 60 ms 2792 KB Output is correct
28 Correct 45 ms 2792 KB Output is correct
29 Correct 34 ms 2772 KB Output is correct
30 Correct 59 ms 2628 KB Output is correct
31 Correct 72 ms 2636 KB Output is correct
32 Correct 60 ms 2772 KB Output is correct
33 Correct 62 ms 2648 KB Output is correct
34 Correct 32 ms 2816 KB Output is correct
35 Correct 95 ms 2652 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Execution timed out 5060 ms 2808 KB Time limit exceeded
40 Halted 0 ms 0 KB -