Submission #903862

# Submission time Handle Problem Language Result Execution time Memory
903862 2024-01-11T12:39:50 Z adaawf Marshmallow Molecules (CCO19_day2problem2) C++14
25 / 25
83 ms 11400 KB
#include <iostream>
#include <set>
using namespace std;
set<int> s[100005];
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    long long int n, m, c = 0;
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        s[u].insert(v);
    }
    for (int i = 1; i <= n; i++) {
        if (s[i].empty()) continue;
        c += s[i].size();
        int h = *s[i].begin();
        s[i].erase(s[i].begin());
        if (s[i].size() > s[h].size()) s[h].swap(s[i]);
        for (int w : s[i]) s[h].insert(w);
        s[i].clear();
    }
    cout << c;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 5212 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Correct 2 ms 5316 KB Output is correct
7 Correct 2 ms 5212 KB Output is correct
8 Correct 2 ms 5220 KB Output is correct
9 Correct 1 ms 4960 KB Output is correct
10 Correct 2 ms 5220 KB Output is correct
11 Correct 2 ms 5212 KB Output is correct
12 Correct 2 ms 5216 KB Output is correct
13 Correct 2 ms 5172 KB Output is correct
14 Correct 2 ms 5224 KB Output is correct
15 Correct 1 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 5212 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Correct 2 ms 5316 KB Output is correct
7 Correct 2 ms 5212 KB Output is correct
8 Correct 2 ms 5220 KB Output is correct
9 Correct 1 ms 4960 KB Output is correct
10 Correct 2 ms 5220 KB Output is correct
11 Correct 2 ms 5212 KB Output is correct
12 Correct 2 ms 5216 KB Output is correct
13 Correct 2 ms 5172 KB Output is correct
14 Correct 2 ms 5224 KB Output is correct
15 Correct 1 ms 4960 KB Output is correct
16 Correct 49 ms 10592 KB Output is correct
17 Correct 38 ms 10592 KB Output is correct
18 Correct 53 ms 10608 KB Output is correct
19 Correct 36 ms 10600 KB Output is correct
20 Correct 55 ms 10772 KB Output is correct
21 Correct 3 ms 5208 KB Output is correct
22 Correct 39 ms 10588 KB Output is correct
23 Correct 41 ms 10520 KB Output is correct
24 Correct 36 ms 10496 KB Output is correct
25 Correct 35 ms 10588 KB Output is correct
26 Correct 38 ms 10692 KB Output is correct
27 Correct 3 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 10764 KB Output is correct
2 Correct 59 ms 10800 KB Output is correct
3 Correct 46 ms 10840 KB Output is correct
4 Correct 48 ms 10844 KB Output is correct
5 Correct 46 ms 10840 KB Output is correct
6 Correct 49 ms 10964 KB Output is correct
7 Correct 48 ms 10620 KB Output is correct
8 Correct 56 ms 10956 KB Output is correct
9 Correct 44 ms 11088 KB Output is correct
10 Correct 58 ms 10852 KB Output is correct
11 Correct 47 ms 10948 KB Output is correct
12 Correct 45 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4952 KB Output is correct
3 Correct 4 ms 5212 KB Output is correct
4 Correct 2 ms 5212 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Correct 2 ms 5316 KB Output is correct
7 Correct 2 ms 5212 KB Output is correct
8 Correct 2 ms 5220 KB Output is correct
9 Correct 1 ms 4960 KB Output is correct
10 Correct 2 ms 5220 KB Output is correct
11 Correct 2 ms 5212 KB Output is correct
12 Correct 2 ms 5216 KB Output is correct
13 Correct 2 ms 5172 KB Output is correct
14 Correct 2 ms 5224 KB Output is correct
15 Correct 1 ms 4960 KB Output is correct
16 Correct 49 ms 10592 KB Output is correct
17 Correct 38 ms 10592 KB Output is correct
18 Correct 53 ms 10608 KB Output is correct
19 Correct 36 ms 10600 KB Output is correct
20 Correct 55 ms 10772 KB Output is correct
21 Correct 3 ms 5208 KB Output is correct
22 Correct 39 ms 10588 KB Output is correct
23 Correct 41 ms 10520 KB Output is correct
24 Correct 36 ms 10496 KB Output is correct
25 Correct 35 ms 10588 KB Output is correct
26 Correct 38 ms 10692 KB Output is correct
27 Correct 3 ms 5212 KB Output is correct
28 Correct 52 ms 10764 KB Output is correct
29 Correct 59 ms 10800 KB Output is correct
30 Correct 46 ms 10840 KB Output is correct
31 Correct 48 ms 10844 KB Output is correct
32 Correct 46 ms 10840 KB Output is correct
33 Correct 49 ms 10964 KB Output is correct
34 Correct 48 ms 10620 KB Output is correct
35 Correct 56 ms 10956 KB Output is correct
36 Correct 44 ms 11088 KB Output is correct
37 Correct 58 ms 10852 KB Output is correct
38 Correct 47 ms 10948 KB Output is correct
39 Correct 45 ms 10832 KB Output is correct
40 Correct 83 ms 10800 KB Output is correct
41 Correct 66 ms 10796 KB Output is correct
42 Correct 65 ms 10844 KB Output is correct
43 Correct 78 ms 10832 KB Output is correct
44 Correct 49 ms 10880 KB Output is correct
45 Correct 64 ms 10832 KB Output is correct
46 Correct 38 ms 10788 KB Output is correct
47 Correct 38 ms 10828 KB Output is correct
48 Correct 35 ms 10836 KB Output is correct
49 Correct 61 ms 10832 KB Output is correct
50 Correct 50 ms 10832 KB Output is correct
51 Correct 48 ms 10820 KB Output is correct
52 Correct 63 ms 10832 KB Output is correct
53 Correct 50 ms 10832 KB Output is correct
54 Correct 65 ms 10836 KB Output is correct
55 Correct 54 ms 10832 KB Output is correct
56 Correct 49 ms 11400 KB Output is correct
57 Correct 35 ms 10576 KB Output is correct