Submission #1063942

#TimeUsernameProblemLanguageResultExecution timeMemory
1063942parsadox2Longest Trip (IOI23_longesttrip)C++17
40 / 100
70 ms708 KiB
#include "longesttrip.h" #include <bits/stdc++.h> using namespace std; const int N = 256; int n , d; bool in_path[N]; vector <int> maximal() { for(int i = 0 ; i < n ; i++) in_path[i] = false; vector <int> vec; vec.push_back(0); in_path[0] = true; while(vec.size() < n) { vector <int> A; A.push_back(vec.back()); vector <int> B; for(int i = 0 ; i < n ; i++) if(!in_path[i]) B.push_back(i); if(!are_connected(A , B)) break; int low = 0 , high = B.size(); while(high - low > 1) { int mid = (low + high) >> 1; vector <int> tmp; for(int i = low ; i < mid ; i++) tmp.push_back(B[i]); if(are_connected(A , tmp)) high = mid; else low = mid; } in_path[B[low]] = true; vec.push_back(B[low]); } reverse(vec.begin() , vec.end()); while(vec.size() < n) { vector <int> A; A.push_back(vec.back()); vector <int> B; for(int i = 0 ; i < n ; i++) if(!in_path[i]) B.push_back(i); if(!are_connected(A , B)) break; int low = 0 , high = B.size(); while(high - low > 1) { int mid = (low + high) >> 1; vector <int> tmp; for(int i = low ; i < mid ; i++) tmp.push_back(B[i]); if(are_connected(A , tmp)) high = mid; else low = mid; } in_path[B[low]] = true; vec.push_back(B[low]); } return vec; } vector<int> longest_trip(int nn, int dd) { n = nn; d = dd; vector <int> vec = maximal(); if(vec.size() > n / 2) return vec; vector <int> comp; for(int i = 0 ; i < n ; i++) if(!in_path[i]) comp.push_back(i); return comp; return vec; }

Compilation message (stderr)

longesttrip.cpp: In function 'std::vector<int> maximal()':
longesttrip.cpp:17:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     while(vec.size() < n)
      |           ~~~~~~~~~~~^~~
longesttrip.cpp:41:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |     while(vec.size() < n)
      |           ~~~~~~~~~~~^~~
longesttrip.cpp: In function 'std::vector<int> longest_trip(int, int)':
longesttrip.cpp:72:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   72 |     if(vec.size() > n / 2)
      |        ~~~~~~~~~~~^~~~~~~
#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...