Submission #856911

#TimeUsernameProblemLanguageResultExecution timeMemory
856911IS_RushdiLongest Trip (IOI23_longesttrip)C++17
5 / 100
42 ms1476 KiB
#include<bits/stdc++.h> using namespace std; #include "longesttrip.h" vector<int> longest_trip(int n, int k) { vector<int>ans; if(k == 3) for(int i = 0; i < n; i++) ans.push_back(i); else if(k == 2){ int v = 0; ans.push_back(0); vector<int>a; for(int i = 1; i < n; i++) a.push_back(i); for(int i = 1; i < n; i++){ vector<int>wow; wow.push_back(v); vector<int>arr = a; while(arr.size() > 1){ int m = arr.size()/2; vector<int>newarr; for(int j = 0; j < m; j++) newarr.push_back(arr[j]); bool ok = are_connected(wow,newarr); if(ok){ arr = newarr; }else{ vector<int>newarr2; for(int j = m; j < arr.size(); j++) newarr2.push_back(arr[j]); arr = newarr2; } } vector<int>A; for(int i = 0; i < a.size(); i++){ if(a[i] == arr[0]) continue; A.push_back(a[i]); } a = A; v = arr[0]; ans.push_back(v); } } return ans; } // int main(){ // }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:25:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |                     for(int j = m; j < arr.size(); j++) newarr2.push_back(arr[j]);
      |                                    ~~^~~~~~~~~~~~
longesttrip.cpp:30:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |             for(int i = 0; i < a.size(); i++){
      |                            ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...