Submission #417004

#TimeUsernameProblemLanguageResultExecution timeMemory
417004vanicRail (IOI14_rail)C++14
0 / 100
468 ms148868 KiB
#include "rail.h" #include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <algorithm> using namespace std; const int maxn=5e3+5; int dist[maxn][maxn]; int posevi[maxn]; int boje[maxn]; void rijesi(int x, int pos, int boja, vector < int > svi){ posevi[x]=pos; boje[x]=boja; if(svi.empty()){ return; } int iduc; int mini=1e9; for(int i=0; i<(int)svi.size(); i++){ if(mini>dist[x][svi[i]]){ mini=dist[x][svi[i]]; iduc=svi[i]; } } vector < int > l, d; for(int i=0; i<(int)svi.size(); i++){ if(svi[i]==iduc){ continue; } if(dist[iduc][svi[i]]<dist[x][svi[i]]){ l.push_back(svi[i]); } else{ d.push_back(svi[i]); } } rijesi(x, pos, boja, d); if(boja==1){ rijesi(iduc, x+dist[x][iduc], 2, l); } else{ rijesi(iduc, x-dist[x][iduc], 1, l); } } void findLocation(int n, int pos, int sol1[], int sol2[]){ vector < int > svi; for(int i=0; i<n; i++){ if(i){ svi.push_back(i); } for(int j=i+1; j<n; j++){ dist[i][j]=getDistance(i, j); dist[j][i]=dist[i][j]; } } rijesi(0, pos, 1, svi); for(int i=0; i<n; i++){ sol1[i]=posevi[i]; sol2[i]=boje[i]; } }

Compilation message (stderr)

rail.cpp: In function 'void rijesi(int, int, int, std::vector<int>)':
rail.cpp:44:30: warning: 'iduc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |   rijesi(iduc, x+dist[x][iduc], 2, l);
      |                  ~~~~~~~~~~~~^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...