Submission #745431

#TimeUsernameProblemLanguageResultExecution timeMemory
745431AlexandruabcdeMarshmallow Molecules (CCO19_day2problem2)C++14
5 / 25
4080 ms220912 KiB
#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());

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

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

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

    return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:33:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for (int j = 0; j < G[i].size(); ++ j ) {
      |                         ~~^~~~~~~~~~~~~
Main.cpp:34:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for (int k = j+1; k < G[i].size(); ++ k ) {
      |                               ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...