Submission #848774

#TimeUsernameProblemLanguageResultExecution timeMemory
848774emad234Longest Trip (IOI23_longesttrip)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(v) ((v).begin(),(v).end()) #define ll long long #define F first #define S second const ll mod = 1e9 + 7; const ll mxN = 2e5 + 1; using namespace std; int Search(int x, vector<int>b){ if(b.size() == 1) return b[0]; vector<int>a = {x}; vector<int> v,v1; for(int i = 0;i < b.size() / 2;i++) v.push_back(b[i]); for(int i = b.size() / 2;i < b.size();i++) v1.push_back(b[i]); if(are_connected(a,v)) return Search(x,v); else if(are_connected(a,v1)) return Search(x,v1); return -1; } bool vis[mxN]; vector<int> longest_trip(int N, int D) { vector<int>ans = {0}; vis[0] = 1; while(ans.size() < N){ vector<int>b; for(int i = 0;i < N;i++){ if(!vis[i]) b.push_back(i); } int x = Search(ans[ans.size() - 1],b); ans.push_back(x); vis[x] = 1; } return ans; }

Compilation message (stderr)

longesttrip.cpp: In function 'int Search(int, std::vector<int>)':
longesttrip.cpp:13:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for(int i = 0;i < b.size() / 2;i++) v.push_back(b[i]);
      |                 ~~^~~~~~~~~~~~~~
longesttrip.cpp:14:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for(int i = b.size() / 2;i < b.size();i++) v1.push_back(b[i]);
      |                            ~~^~~~~~~~~~
longesttrip.cpp:15:6: error: 'are_connected' was not declared in this scope
   15 |   if(are_connected(a,v)) return Search(x,v);
      |      ^~~~~~~~~~~~~
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:24:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   while(ans.size() < N){
      |         ~~~~~~~~~~~^~~