Submission #853586

#TimeUsernameProblemLanguageResultExecution timeMemory
853586AndreyLongest Trip (IOI23_longesttrip)C++17
15 / 100
773 ms1176 KiB
#include "longesttrip.h" #include<bits/stdc++.h> using namespace std; bool haha[1000][1000]; vector<int> longest_trip(int n, int d) { for(int i = 0; i < n; i++) { haha[i][i] = false; for(int j = i+1; j < n; j++) { bool c = are_connected({i},{j}); haha[i][j] = c; haha[j][i] = c; } } vector<bool> bruh(n,true); deque<int> ans; ans.push_back(0); bruh[0] = false; for(int i = 1; i < n; i++) { if(haha[0][i]) { ans.push_back(i); bruh[i] = false; break; } } for(int i = 2; i < n; i++) { int p; for(int j = 0; j < n; j++) { if(bruh[j]) { p = j; } } int a = ans[0],b = ans[ans.size()-1]; if(haha[a][p]) { ans.push_front(p); bruh[p] = false; } else if(haha[b][p]) { ans.push_back(p); bruh[p] = false; } else { int c = -1; for(int j = 0; j < n; j++) { for(int y = 0; y < n; y++) { if(bruh[j] == false && bruh[y] == true && haha[j][y]) { c = y; } } } if(c == -1) { break; } ans.push_back(c); bruh[c] = false; } } vector<int> wut(0); for(int i = 0; i < ans.size(); i++) { wut.push_back(ans[i]); } if(ans.size() == n) { return wut; } else { if(ans.size() < n-ans.size()) { wut.clear(); for(int i = 0; i < n; i++) { if(bruh[i]) { wut.push_back(i); } } } } return wut; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i = 0; i < ans.size(); i++) {
      |                    ~~^~~~~~~~~~~~
longesttrip.cpp:64:19: warning: comparison of integer expressions of different signedness: 'std::deque<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   64 |     if(ans.size() == n) {
      |        ~~~~~~~~~~~^~~~
#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...