Submission #1081773

#TimeUsernameProblemLanguageResultExecution timeMemory
1081773ArthuroWichLongest Trip (IOI23_longesttrip)C++17
40 / 100
17 ms644 KiB
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; vector<int> longest_trip(int n, int d) { vector<int> a, b, ans; a = {0}; b = {1}; for (int i = 2; i < n; i++) { if (are_connected({a.back(), b.back()}, {i})) { if (are_connected({a.back()}, {i})) { a.push_back(i); } else { b.push_back(i); } } else { for (int j = b.size()-1; j >= 0; j--) { a.push_back(b[j]); } b = {i}; } } if (are_connected(a, b)) { if (are_connected({a.front()}, {b.front()})) { reverse(a.begin(), a.end()); for (int j = 0; j < b.size(); j++) { a.push_back(b[j]); } reverse(a.begin(), a.end()); b.clear(); } else if (are_connected({a.back()}, {b.front()})) { for (int j = 0; j < b.size(); j++) { a.push_back(b[j]); } b.clear(); } else if (are_connected({a.front()}, {b.back()})) { reverse(a.begin(), a.end()); for (int j = b.size()-1; j >= 0; j--) { a.push_back(b[j]); } reverse(a.begin(), a.end()); b.clear(); } else if (are_connected({a.back()}, {b.back()})) { for (int j = b.size()-1; j >= 0; j--) { a.push_back(b[j]); } b.clear(); } } if (a.size() >= b.size()) { ans = a; } else { ans = b; } return ans; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:25:31: 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 = 0; j < b.size(); j++) {
      |                             ~~^~~~~~~~~~
longesttrip.cpp:31:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             for (int j = 0; j < b.size(); j++) {
      |                             ~~^~~~~~~~~~
#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...