Submission #1134718

#TimeUsernameProblemLanguageResultExecution timeMemory
1134718Ak_16Rail (IOI14_rail)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int dis1[10000]; int sp; int dis2[10000]; int sta[10000]; int mnd; struct pla{ int x, y; }; vector<pla> lef; vector<pla> rig; bool cmp1(const pla &a, const pla&b){ return a.y > b.y; } bool cmp2(const pla &a, const pla&b){ return a.y < b.y; } int getDistance(int i, int j); void findLocation(int m, int first, int location[], int stype[]){ location[0] = first; stype[0]=1; sp = 0; sta[0] = 2; mnd = 100000000; for(int i=1; i<m; i++){ dis1[i] = getDistance(0, i); if(dis1[i]<mnd){sp = i; mnd = dis1[i];} } location[sp] = first + dis1[sp]; stype[sp]=2; sta[sp] = 2; mnd = 100000000; for(int i=1; i<m; i++){ if(i!=sp){ dis2[i] = getDistance(sp, i); if(dis1[i] == dis2[i] + dis1[sp]){ if(dis2[i]<dis1[sp]){sta[i] = 2; location[i] = location[sp] - dis2[i]; stype[i] = 1;} else {sta[i] = 1;} } else {sta[i] = 3;} } } for(int i=1; i<m; i++){ if(sta[i]==1){ lef.push_back({i, dis2[i]}); } if(sta[i]==3){ rig.push_back({i, dis1[i]}); } } sort(rig.begin(), rig.end(), cmp2); sort(lef.begin(), lef.end(), cmp2); int cur = sp; for(const auto &inf : rig){ int n1 = inf.x; int n2 = inf.y; if(cur==sp){ location[n1] = first + n2; stype[n1] = 2; cur = n1; } else { int n3 = getDistance(cur, n1); if(n2 == n3 + dis1[cur]){ location[n1] = location[cur] - n3; stype[n1] = 1; } else { location[n1] = first + n2; stype[n1] = 2; cur = n1; } } } cur = 0; for(const auto &inf : lef){ int n1 = inf.x; int n2 = inf.y; if(cur==0){ location[n1] = location[sp] - n2; stype[n1] = 1; cur = n1; } else { int n3 = getDistance(cur, n1); if(n2 == n3 + dis1[cur]){ location[n1] = location[cur] + n3; stype[n1] = 2; } else { location[n1] = location[sp] - n2; stype[n1] = 1; cur = n1; } } } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccSv5o94.o: in function `findLocation(int, int, int*, int*)':
rail.cpp:(.text+0x9e): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x13a): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x570): undefined reference to `getDistance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x61e): undefined reference to `getDistance(int, int)'
/usr/bin/ld: /tmp/ccT8W5u3.o: in function `main':
grader.cpp:(.text.startup+0x2d9): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status