Submission #375324

#TimeUsernameProblemLanguageResultExecution timeMemory
375324astoriaFun Tour (APIO20_fun)C++14
26 / 100
61 ms26596 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}; } } int mxd=0,mxp=-1; for(int i=0; i<N; i++){ sort(dist[i],dist[i]+N); reverse(dist[i],dist[i]+N); if(dist[i][0].first>mxd){ mxd = dist[i][0].first; mxp = i;} } for(int st=mxp; st<mxp+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:36:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   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...