Submission #1043729

#TimeUsernameProblemLanguageResultExecution timeMemory
1043729pravcoderRail (IOI14_rail)C++14
30 / 100
33 ms604 KiB
#include "rail.h" #include <vector> #include <cmath> #include <iostream> #include <cstdio> #include <algorithm> using namespace std; typedef vector<int> vi; #define rep(i, n) for (int i = 0; i<n; i++) #define pb push_back void findLocation(int N, int first, int location[], int stype[]) { vi cs; vi ds; vi zdists; zdists.pb(0); rep(i, N - 1) { zdists.pb(getDistance(0, i + 1)); } for (int i = 1; i < N-1; i++) { int newdist = getDistance(i, N-1); int dist1 = zdists[i]; int dist2 = zdists[N-1]; if (newdist == dist1 + dist2) { ds.pb(i); ds.pb(N-1); //cout << "found d\n"; } else if (newdist == dist1 - dist2) { //cs.pb(i); ds.pb(N-1); //cout << "found d\n"; } else if (newdist == dist2 - dist1) { ds.pb(i); //cs.pb(2*i + 2); //cout << "found d\n"; } } int fd = ds[0]; ds.resize(1, N-1); //cout << "finding cs\n"; int mind = N - 1; rep(i, N) { if (i != fd) { //cout << "testing " << i << "\n"; if (i == 0) { cs.pb(i); } else { int newdist = getDistance(i, fd); int dist1 = zdists[i]; int dist2 = zdists[fd]; //cout << " ? "; if (newdist == dist1 + dist2) { ds.pb(i); if (zdists[i] < zdists[fd]) { mind = i; } } else { cs.pb(i); } } } } for (auto d : ds) { location[d] = first + zdists[d]; stype[d] = 2; } for (auto c : cs) { location[c] = first + zdists[fd] - getDistance(fd, c); stype[c] = 1; } stype[0] = 1; location[0] = first; return; }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:51:9: warning: variable 'mind' set but not used [-Wunused-but-set-variable]
   51 |     int mind = N - 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...