Submission #745448

# Submission time Handle Problem Language Result Execution time Memory
745448 2023-05-20T06:59:04 Z Alexandruabcde Marshmallow Molecules (CCO19_day2problem2) C++14
5 / 25
4000 ms 826896 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair <int, int> PII;
constexpr int NMAX = 1e5 + 5;

int N, M;
vector <int> G[NMAX];

map <PII, int> mp;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> M;

    for (int i = 1; i <= M; ++ i ) {
        int x, y;
        cin >> x >> y;

        if (x > y) swap(x, y);
        G[x].push_back(y);

        mp[{x, y}] = true;
    }

    for (int i = 1; i <= N; ++ i ) {
        sort(G[i].begin(), G[i].end());

        if (G[i].empty()) continue;

        int x = G[i][0];
        for (int j = 1; j < G[i].size(); ++ j ) {
            int y = G[i][j];

            if (!mp[{x, y}]) {
                G[x].push_back(y);
                mp[{x, y}] = true;
            }
        }
    }

    cout << mp.size() << '\n';

    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:36:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for (int j = 1; j < G[i].size(); ++ j ) {
      |                         ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 5 ms 3028 KB Output is correct
4 Correct 4 ms 2900 KB Output is correct
5 Correct 3 ms 2948 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 3 ms 3028 KB Output is correct
9 Correct 2 ms 2900 KB Output is correct
10 Correct 3 ms 2940 KB Output is correct
11 Correct 5 ms 2900 KB Output is correct
12 Correct 4 ms 3028 KB Output is correct
13 Correct 3 ms 3028 KB Output is correct
14 Correct 4 ms 3028 KB Output is correct
15 Correct 3 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 5 ms 3028 KB Output is correct
4 Correct 4 ms 2900 KB Output is correct
5 Correct 3 ms 2948 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 3 ms 3028 KB Output is correct
9 Correct 2 ms 2900 KB Output is correct
10 Correct 3 ms 2940 KB Output is correct
11 Correct 5 ms 2900 KB Output is correct
12 Correct 4 ms 3028 KB Output is correct
13 Correct 3 ms 3028 KB Output is correct
14 Correct 4 ms 3028 KB Output is correct
15 Correct 3 ms 2900 KB Output is correct
16 Correct 3897 ms 768264 KB Output is correct
17 Correct 3926 ms 798904 KB Output is correct
18 Execution timed out 4102 ms 826896 KB Time limit exceeded
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4106 ms 780420 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 5 ms 3028 KB Output is correct
4 Correct 4 ms 2900 KB Output is correct
5 Correct 3 ms 2948 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 3 ms 3028 KB Output is correct
9 Correct 2 ms 2900 KB Output is correct
10 Correct 3 ms 2940 KB Output is correct
11 Correct 5 ms 2900 KB Output is correct
12 Correct 4 ms 3028 KB Output is correct
13 Correct 3 ms 3028 KB Output is correct
14 Correct 4 ms 3028 KB Output is correct
15 Correct 3 ms 2900 KB Output is correct
16 Correct 3897 ms 768264 KB Output is correct
17 Correct 3926 ms 798904 KB Output is correct
18 Execution timed out 4102 ms 826896 KB Time limit exceeded
19 Halted 0 ms 0 KB -