Submission #847213

#TimeUsernameProblemLanguageResultExecution timeMemory
847213Trisanu_DasLongest Trip (IOI23_longesttrip)C++17
Compilation error
0 ms0 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; vector<int> longest_trip(int N, int D) { vector<int> ans = {0}; vector<bool> vis(N, false); vis[0] = true; int adj[N][N]; memset(adj, -1, sizeof(adj)); auto is_connected = [&] (int x, int y) { if (adj[x][y] >= 0) return adj[x][y]; adj[x][y] = adj[y][x] = are_connected({x}, {y}); return adj[x][y]; }; while (true) { if (ans.size() == N) return ans; bool flag = false; for (int i = 0; i < N && !flag; i++) { if (!vis[i]) { if (is_connected(ans[0], i)) { ans.insert(ans.begin(), i); flag = vis[i] = true; break; } if (is_connected(ans.back(), i)) { ans.push_back(i); flag = vis[i] = true; break; } for (int j = 0; j < ans.size(); j++) { if (is_connected(ans[j], i)) { vector<int> new_path; new_path.insert(new_path.end(), ans.begin() + j + 1, ans.end()); new_path.insert(new_path.end(), ans.begin(), ans.begin() + j + 1); ans = new_path; ans.push_back(i); flag = vis[i] = true; break; } } } } if (!flag) { if (ans.size() >= (N - ans.size())) return ans; ans.clear(); for (int i = 0; i < N; i++) if (!vis[i]) ans.push_back(i); return ans; } } }

Compilation message (stderr)

longesttrip.cpp: In lambda function:
longesttrip.cpp:11:13: sorry, unimplemented: capture of variably-modified type 'int [N][N]' that is not an N3639 array of runtime bound
   11 |         if (adj[x][y] >= 0) return adj[x][y];
      |             ^~~
longesttrip.cpp:11:13: note: because the array element type 'int [N]' has variable size
longesttrip.cpp:11:36: sorry, unimplemented: capture of variably-modified type 'int [N][N]' that is not an N3639 array of runtime bound
   11 |         if (adj[x][y] >= 0) return adj[x][y];
      |                                    ^~~
longesttrip.cpp:11:36: note: because the array element type 'int [N]' has variable size
longesttrip.cpp:12:9: sorry, unimplemented: capture of variably-modified type 'int [N][N]' that is not an N3639 array of runtime bound
   12 |         adj[x][y] = adj[y][x] = are_connected({x}, {y});
      |         ^~~
longesttrip.cpp:12:9: note: because the array element type 'int [N]' has variable size
longesttrip.cpp:12:21: sorry, unimplemented: capture of variably-modified type 'int [N][N]' that is not an N3639 array of runtime bound
   12 |         adj[x][y] = adj[y][x] = are_connected({x}, {y});
      |                     ^~~
longesttrip.cpp:12:21: note: because the array element type 'int [N]' has variable size
longesttrip.cpp:13:16: sorry, unimplemented: capture of variably-modified type 'int [N][N]' that is not an N3639 array of runtime bound
   13 |         return adj[x][y];
      |                ^~~
longesttrip.cpp:13:16: note: because the array element type 'int [N]' has variable size
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:16:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |         if (ans.size() == N) return ans;
      |             ~~~~~~~~~~~^~~~
longesttrip.cpp:30:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |                 for (int j = 0; j < ans.size(); j++) {
      |                                 ~~^~~~~~~~~~~~