Submission #128640

#TimeUsernameProblemLanguageResultExecution timeMemory
128640antimirageRail (IOI14_rail)C++14
0 / 100
86 ms604 KiB
#include "rail.h" #include <bits/stdc++.h> #define fr first #define sc second #define mk make_pair #define pb push_back #define all(s) s.begin(), s.end() using namespace std; const int N = 5005; int dist[2][N]; vector <int> lft; bool cmp2 (int a, int b) { return dist[1][a] < dist[1][b]; } void findLocation(int n, int pos, int a[], int t[]) { int mx = 0, ind, asd; a[0] = pos, t[0] = 1; if (n == 1) return; for (int i = 1; i < n; i++) { dist[0][i] = getDistance(0, i); if (dist[0][i] > mx) { mx = dist[0][i]; ind = i; } } a[ind] = pos + mx; t[ind] = 2; for (int i = 1; i < n; i++) { if (i == ind) continue; dist[1][i] = getDistance(ind, i); lft.pb(i); } sort(all(lft), cmp2); int lastc = -1, lastd = ind; for (int i = 0; i < (int)lft.size(); i++) { int it = lft[i]; if (lastc == -1) { lastc = it; a[it] = a[ind] - dist[1][it]; t[it] = 1; } else { int res = getDistance(lastc, it), nxt = a[ind] - dist[1][it]; if (nxt >= 0 && res == 2 * (a[lastd] - a[lastc]) + a[lastc] - nxt) { a[it] = nxt, lastc = it; t[it] = 1; } else { a[it] = a[lastc] + res; t[it] = 2; if (a[lastd] > a[it]) lastd = it; } } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:24:19: warning: unused variable 'asd' [-Wunused-variable]
  int mx = 0, ind, asd;
                   ^~~
rail.cpp:36:7: warning: 'ind' may be used uninitialized in this function [-Wmaybe-uninitialized]
  a[ind] = pos + mx; t[ind] = 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...