Submission #610489

#TimeUsernameProblemLanguageResultExecution timeMemory
610489Minindu2006Rail (IOI14_rail)C++14
56 / 100
381 ms716 KiB
#include "rail.h" #include <bits/stdc++.h> using namespace std; const int MX = 1e9; void findLocation(int N, int first, int location[], int stype[]) { location[0] = first; stype[0] = 1; vector<int> curdis1(N, MX), vis(N, 0); curdis1[0] = 0; // int cmin = MX, sec = -1; // for(int i=1;i<N;i++) // { // int d = getDistance(0, i); // curdis1[i] = d; // if(d < cmin) // { // cmin = d; // sec = i; // } // } // location[sec] = first + cmin, stype[sec] = 2; // vis[0] = 1; for (int i = 0; i < N; i++) { int nxt, cids = MX; for (int j = 0; j < N; j++) { if (vis[j]) continue; if (curdis1[j] < cids) nxt = j, cids = curdis1[j]; } for (int j = 0; j < N; j++) { if (vis[j] || j == nxt) continue; int curd = getDistance(nxt, j), delta = (stype[nxt] == 1 ? +1 : -1); if (curd < curdis1[j]) { curdis1[j] = curd; location[j] = location[nxt] + curd * delta; stype[j] = (stype[nxt] == 1 ? 2 : 1); } } vis[nxt] = 1; // } // for(int i=0;i<N;i++) // cout << location[i] << " "; // cout << '\n'; } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:38:35: warning: 'nxt' may be used uninitialized in this function [-Wmaybe-uninitialized]
   38 |             int curd = getDistance(nxt, j), delta = (stype[nxt] == 1 ? +1 : -1);
      |                        ~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...