Submission #290230

#TimeUsernameProblemLanguageResultExecution timeMemory
290230AaronNaiduRail (IOI14_rail)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int distFrom0[5001]; int distFromMin[5001]; int queries[5001][5001]; int closest[5001]; bool doneWith[5001]; vector<int> goesTo[5001]; int getDistance(int i ,int j) { cout << "Distance " << i << " " << j << "\n"; int x; cin >> x; return x; } void findLocation(int n, int first, int location[], int sType[]) { location[0] = first; sType[0] = 1; doneWith[0] = true; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { queries[i][j] = getDistance(i,j); queries[j][i] = queries[i][j]; } } for (int i = 0; i < n; i++) { int minDist = 1000000007; int minIndex = -1; for (int j = 0; j < n; j++) { if (j != i and queries[i][j] < minDist) { minDist = queries[i][j]; closest[i] = j; } } } for (int i = 0; i < n; i++) { goesTo[closest[i]].push_back(i); } int numDone = n-1; queue<int> q; q.push(0); while (!q.empty()) { int x = q.front(); q.pop(); if (!doneWith[closest[x]]) { q.push(closest[x]); doneWith[closest[x]] = true; if (sType[x] == 1) { sType[closest[x]] = 2; location[closest[x]] = location[x] + queries[x][closest[x]]; } else { sType[closest[x]] = 1; location[closest[x]] = location[x] - queries[x][closest[x]]; } } for (auto i : goesTo[x]) { if (!doneWith[i]) { q.push(i); doneWith[i] = true; if (sType[x] == 1) { sType[i] = 2; location[i] = location[x] + queries[x][i]; } else { sType[i] = 1; location[i] = location[x] - queries[x][i]; } } } } }

Compilation message (stderr)

rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:33:13: warning: unused variable 'minIndex' [-Wunused-variable]
   33 |         int minIndex = -1;
      |             ^~~~~~~~
rail.cpp:47:9: warning: unused variable 'numDone' [-Wunused-variable]
   47 |     int numDone = n-1;
      |         ^~~~~~~
/tmp/ccpro9LJ.o: In function `main':
grader.cpp:(.text.startup+0x291): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status