Submission #1056379

#TimeUsernameProblemLanguageResultExecution timeMemory
1056379IgnutLongest Trip (IOI23_longesttrip)C++17
15 / 100
753 ms592 KiB
/* Ignut
started: 13.08.2024
now: 13.08.2024
████████████████████████████████████████████████████████████████████
████████████████████████████████    ████████████████████████████████
██████████████████████████████        ██████████████████████████████
██████      ██████████████████        ██████████████████      ██████
██████          ██████████████        ██████████████          ██████
██████      ██    ████████████        ████████████    ██      ██████
██████      ████    ██████████        ██████████    ████      ██████
██████      ████      ██████████    ██████████      ████      ██████
██████      ████      ██████████    ██████████    ██████      ██████
██████      ██████    ██████████    ██████████    ██████      ██████
██████      ██████    ████████        ████████    ██████      ██████
██████      ██████      ██████        ██████      ██████      ██████
██████      ████        ████            ████        ████      ██████
██████            ██████████    ████    ██████████            ██████
██████      ██      ██████    ████████    ██████      ██      ██████
██████      ██████            ████████            ██████      ██████
██████                    ██            ██                    ██████
██████████████████████      ████    ████      ██████████████████████
████████████████████████      ██    ██      ████████████████████████
██████████████████████████                ██████████████████████████
██████████████████████████████        ██████████████████████████████
████████████████████████████████████████████████████████████████████
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

bool are_connected(vector<int> A, vector<int> B);

vector<int> longest_trip(int N, int D) {
    if (D == 3) {
        vector<int> vec;
        for (int i = 0; i < N; i ++) vec.push_back(i);
        return vec;
    }
    vector<pair<int, int>> lst;
    int cnt[N] = {};
    for (int i = 0; i < N; i ++) {
        for (int j = i + 1; j < N; j ++) {
            if (!are_connected({i}, {j})) {
                lst.push_back({i, j});
                cnt[i] ++, cnt[j] ++;
            }
        }
    }
    vector<int> free;
    for (int i = 0; i < N; i ++) if (cnt[i] == 0) free.push_back(i);

    vector<int> res;
    for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].first);
    for (int val : free) res.push_back(val);
    for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].second);
    return res;
}

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |     for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].first);
      |                     ~~^~~~~~~~~~~~
longesttrip.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 0; i < lst.size(); i ++) res.push_back(lst[i].second);
      |                     ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...