Submission #878559

# Submission time Handle Problem Language Result Execution time Memory
878559 2023-11-24T17:33:22 Z thinknoexit Longest Trip (IOI23_longesttrip) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "longesttrip.h"
using namespace std;
using ll = long long;
int n, d;
bool adj[256][256];
vector<int> longest_trip(int N, int D) {
    n = N;
    d = D;
    memset(adj, 0, sizeof adj);
    for (int i = 0;i < n;i++) {
        for (int j = i + 1;j < n;j++) {
            adj[i][j] = adj[j][i] = are_connected({ i }, { j });
        }
    }
    queue<int> q;
    for (int i = 1;i < n;i++) {
        q.push(i);
    }
    deque<int> ans;
    ans.push_back(0);
    while (!q.empty()) {
        if (adj[ans.back()][q.front()]) {
            ans.push_back(q.front());
            q.pop();
        }
        else {
            ans.push_front(q.front());
            q.pop();
        }
    }
    return ans;
}

Compilation message

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:32:12: error: could not convert 'ans' from 'std::deque<int, std::allocator<int> >' to 'std::vector<int>'
   32 |     return ans;
      |            ^~~
      |            |
      |            std::deque<int, std::allocator<int> >