Submission #375323

#TimeUsernameProblemLanguageResultExecution timeMemory
375323astoriaFun Tour (APIO20_fun)C++14
0 / 100
1 ms384 KiB
#include "bits/stdc++.h" #include "fun.h" using namespace std; std::vector<int> createFunTour(int N, int Q) { pair<int,int> dist[N][N]; for(int i=0; i<N; i++){ for(int j=0; j<N; j++){ dist[i][j] = {hoursRequired(i,j),j}; } } for(int i=0; i<N; i++){ sort(dist[i],dist[i]+N); reverse(dist[i],dist[i]+N); } for(int st=0; st<1; st++){ int v=st,cnt=1; vector<int> ans; ans.push_back(v); int used[N]; memset(used,0,sizeof(used)); used[v]=1; int mn = 1e9+100; while(cnt<N){ int nxt=-1; for(int j=0; j<N; j++){ if(dist[v][j].first <= mn && !used[dist[v][j].second]){ nxt = dist[v][j].second; mn=min(mn,dist[v][j].first); break; } } if(nxt==-1) break; used[nxt]=1; cnt++; v=nxt; ans.push_back(v); } if(ans.size()==N){ return ans; } } exit(6); return std::vector<int>(N); }

Compilation message (stderr)

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:33:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |   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...