Submission #846251

#TimeUsernameProblemLanguageResultExecution timeMemory
846251JoksimKaktusLongest Trip (IOI23_longesttrip)C++17
15 / 100
6 ms600 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; vector<int> longest_trip(int N, int D) { vector <int> v; if(D == 3){ for(int i = 0;i < N;i++){ v.push_back(i); } }else if(D == 2){ int last; if(are_connected({0},{1})){ v.push_back(0); v.push_back(1); if(are_connected({0},{2})){ v.insert(v.begin(),2); last = 1; }else{ v.push_back(2); last = 2; } }else{ v.push_back(0); v.push_back(2); v.push_back(1); last = 1; } for(int i = 3; i < N;i++){ if(are_connected({last},{i})){ v.push_back(i); last = i; }else{ v.insert(v.begin(),i); } } }else{ vector <int>v2; v.push_back(0); int last = 0; if(are_connected({0},{1})){ v.push_back(1); last = 1; }else{ v2.push_back(1); } for(int i = 2;i < N;i++){ if(are_connected({last},{i})){ v.push_back(i); last = i; }else if(are_connected({v[0]},{i})){ v.insert(v.begin(),i); }else{ v2.push_back(i); } } int i1 = -1; int i2 = -1; for(int i = 0; i < v.size();i++){ for(int j = 0;j < v2.size();j++){ if(are_connected({v[i]},{v2[j]})){ i1 = i; i2 = j; break; } } if(i1 != -1){ break; } } if(i1 == -1){ if(v.size() > v2.size()){ return v; } return v2; }else{ vector <int> res; for(int i = 0;i < v.size();i++){ res.push_back(v[(i1+1+i)%v.size()]); } for(int i = 0;i < v2.size();i++){ res.push_back(v[(i2+i)%v2.size()]); } return res; } } return v; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:61:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |         for(int i = 0; i < v.size();i++){
      |                        ~~^~~~~~~~~~
longesttrip.cpp:62:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             for(int j = 0;j < v2.size();j++){
      |                           ~~^~~~~~~~~~~
longesttrip.cpp:80:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |             for(int i = 0;i < v.size();i++){
      |                           ~~^~~~~~~~~~
longesttrip.cpp:83:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |             for(int i = 0;i < v2.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...