Submission #1007036

# Submission time Handle Problem Language Result Execution time Memory
1007036 2024-06-24T11:01:37 Z 3as8 Longest Trip (IOI23_longesttrip) C++17
0 / 100
1 ms 344 KB
#include "longesttrip.h"

#include<bits/stdc++.h>

#define ll long long
using namespace std;

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

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


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

    bool in = false;
    for(int i = 0; i < n; i++) {
        if(!vis[i] && are_connected({startIndex}, {i})) {
            dfs(i, curr);
            in = true;
        }
    }

    if(!in) l = startIndex;
}


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

    n = N;

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

    vector<int> curr2;

    dfs(0, curr);
    dfs(l, curr2);

    return curr2;
}

Compilation message

longesttrip.cpp: In function 'void dfs(long long int, std::vector<int>&)':
longesttrip.cpp:21:38: warning: narrowing conversion of 'startIndex' from 'long long int' to 'int' [-Wnarrowing]
   21 |         if(!vis[i] && are_connected({startIndex}, {i})) {
      |                                      ^~~~~~~~~~
longesttrip.cpp:21:38: warning: narrowing conversion of 'startIndex' from 'long long int' to 'int' [-Wnarrowing]
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:36:8: warning: unused variable 'mx' [-Wunused-variable]
   36 |     ll mx = LLONG_MIN;
      |        ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Incorrect
2 Halted 0 ms 0 KB -