Submission #1007015

# Submission time Handle Problem Language Result Execution time Memory
1007015 2024-06-24T10:55:17 Z 3as8 Longest Trip (IOI23_longesttrip) C++17
0 / 100
990 ms 2097152 KB
#include "longesttrip.h"

#include<bits/stdc++.h>

#define ll long long
using namespace std;

bool con[300][300];
bool vis[300];

ll n;
void dfs(ll startIndex, vector<int>& curr) {


    vis[startIndex] = true;
    curr.push_back(startIndex);

    for(int i = 0; i < n; i++) {
        if(con[startIndex][i] && !vis[i]) {
            dfs(startIndex, curr);
        }
    }

}


std::vector<int> longest_trip(int N, int D) {

    n = N;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {

            con[i][j] = con[j][i] = are_connected({i}, {j});
        }
    }

    vector<ll> ans;
    ll mx = LLONG_MIN;
    for(int j = 0; j < n; j++) vis[j] = false;
    vector<int> curr;
    dfs(0, curr);

    return curr;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:38:8: warning: unused variable 'mx' [-Wunused-variable]
   38 |     ll mx = LLONG_MIN;
      |        ^~
# Verdict Execution time Memory Grader output
1 Runtime error 940 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 952 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 937 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 908 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 990 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -