답안 #816275

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
816275 2023-08-09T04:39:35 Z 이성호(#10126) Marshmallow Molecules (CCO19_day2problem2) C++17
25 / 25
105 ms 24560 KB
#include <iostream>
#include <set>
using namespace std;
set<int> st[100005];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int N, M; cin >> N >> M;
    for (int i = 0; i < M; i++) {
        int a, b; cin >> a >> b;
        st[a].insert(b);
    }
    long long ans = 0;
    for (int i = 1; i <= N; i++) {
        ans += st[i].size();
        if (st[i].empty()) continue;
        int nxt = *st[i].begin();
        st[i].erase(st[i].begin());
        if (st[i].size() > st[nxt].size()) swap(st[i], st[nxt]);
        for (int j:st[i]) st[nxt].insert(j);
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 4 ms 5204 KB Output is correct
4 Correct 2 ms 5076 KB Output is correct
5 Correct 2 ms 5076 KB Output is correct
6 Correct 4 ms 5164 KB Output is correct
7 Correct 4 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 4 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 4 ms 5204 KB Output is correct
4 Correct 2 ms 5076 KB Output is correct
5 Correct 2 ms 5076 KB Output is correct
6 Correct 4 ms 5164 KB Output is correct
7 Correct 4 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 4 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 44 ms 10220 KB Output is correct
17 Correct 42 ms 10080 KB Output is correct
18 Correct 57 ms 9588 KB Output is correct
19 Correct 51 ms 9688 KB Output is correct
20 Correct 55 ms 9680 KB Output is correct
21 Correct 5 ms 5372 KB Output is correct
22 Correct 47 ms 10104 KB Output is correct
23 Correct 51 ms 10036 KB Output is correct
24 Correct 37 ms 9624 KB Output is correct
25 Correct 43 ms 9696 KB Output is correct
26 Correct 38 ms 9692 KB Output is correct
27 Correct 6 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 12936 KB Output is correct
2 Correct 65 ms 12432 KB Output is correct
3 Correct 44 ms 11644 KB Output is correct
4 Correct 66 ms 13952 KB Output is correct
5 Correct 66 ms 12544 KB Output is correct
6 Correct 67 ms 11728 KB Output is correct
7 Correct 54 ms 13924 KB Output is correct
8 Correct 64 ms 12548 KB Output is correct
9 Correct 61 ms 11696 KB Output is correct
10 Correct 56 ms 13924 KB Output is correct
11 Correct 64 ms 12476 KB Output is correct
12 Correct 58 ms 11692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 4 ms 5204 KB Output is correct
4 Correct 2 ms 5076 KB Output is correct
5 Correct 2 ms 5076 KB Output is correct
6 Correct 4 ms 5164 KB Output is correct
7 Correct 4 ms 5076 KB Output is correct
8 Correct 3 ms 5076 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 3 ms 5076 KB Output is correct
12 Correct 4 ms 5076 KB Output is correct
13 Correct 3 ms 5076 KB Output is correct
14 Correct 4 ms 5076 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 44 ms 10220 KB Output is correct
17 Correct 42 ms 10080 KB Output is correct
18 Correct 57 ms 9588 KB Output is correct
19 Correct 51 ms 9688 KB Output is correct
20 Correct 55 ms 9680 KB Output is correct
21 Correct 5 ms 5372 KB Output is correct
22 Correct 47 ms 10104 KB Output is correct
23 Correct 51 ms 10036 KB Output is correct
24 Correct 37 ms 9624 KB Output is correct
25 Correct 43 ms 9696 KB Output is correct
26 Correct 38 ms 9692 KB Output is correct
27 Correct 6 ms 5332 KB Output is correct
28 Correct 91 ms 12936 KB Output is correct
29 Correct 65 ms 12432 KB Output is correct
30 Correct 44 ms 11644 KB Output is correct
31 Correct 66 ms 13952 KB Output is correct
32 Correct 66 ms 12544 KB Output is correct
33 Correct 67 ms 11728 KB Output is correct
34 Correct 54 ms 13924 KB Output is correct
35 Correct 64 ms 12548 KB Output is correct
36 Correct 61 ms 11696 KB Output is correct
37 Correct 56 ms 13924 KB Output is correct
38 Correct 64 ms 12476 KB Output is correct
39 Correct 58 ms 11692 KB Output is correct
40 Correct 71 ms 21956 KB Output is correct
41 Correct 76 ms 21856 KB Output is correct
42 Correct 105 ms 24560 KB Output is correct
43 Correct 77 ms 24548 KB Output is correct
44 Correct 54 ms 18524 KB Output is correct
45 Correct 66 ms 18540 KB Output is correct
46 Correct 42 ms 10692 KB Output is correct
47 Correct 43 ms 10796 KB Output is correct
48 Correct 39 ms 10776 KB Output is correct
49 Correct 38 ms 10724 KB Output is correct
50 Correct 55 ms 13912 KB Output is correct
51 Correct 65 ms 12544 KB Output is correct
52 Correct 50 ms 11688 KB Output is correct
53 Correct 45 ms 11756 KB Output is correct
54 Correct 59 ms 14060 KB Output is correct
55 Correct 58 ms 16216 KB Output is correct
56 Correct 67 ms 13260 KB Output is correct
57 Correct 35 ms 10468 KB Output is correct