제출 #945747

#제출 시각아이디문제언어결과실행 시간메모리
945747WongChun1234철로 (IOI14_rail)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include"rail.h" using namespace std; const int N=5050; int dist[N][4],rf,rrf; int get_distance(int X, int Y); vector<pair<int,int>> srt,ans,l,r; map<int,int> id; void eat(int i,int pos,int ty){ //cerr<<i<<" at pos "<<pos<<" type "<<ty<<endl; ans[i]={pos,ty}; id[pos]=i; } void find_location(int n, int first, int location[], int stype[]) { int q=100000050; ans.resize(n); for (int i=-1000000;i<=1000000;i++) id[i]=5049; for (int i=1;i<n;i++){ dist[i][0]=get_distance(0,i); srt.push_back({dist[i][0],i}); } sort(srt.begin(),srt.end()); rrf=rf=srt[0].second; eat(0,0,1); eat(rf,srt[0].first,2); for (int i=1;i<n;i++){ if (i==rf) continue; dist[i][1]=get_distance(rf,i); if (dist[i][1]+dist[rf][0]==dist[i][0]){ l.push_back({dist[i][1],i}); }else{ r.push_back({dist[i][0],i}); } } sort(l.begin(),l.end()); sort(r.begin(),r.end()); for (pair<int,int> i:r){ cerr<<i.first<<" "<<i.second<<" !!\n"; int dis,ps; dist[i.second][2]=get_distance(rf,i.second); assert(!((dist[i.second][2]+dist[rf][0]-dist[i.second][0])%2)); dis=(dist[i.second][2]+dist[rf][0]-dist[i.second][0])/2; ps=dist[rf][0]-dis; if (ans[id[ps]].second==1){ // --------------> // |---- // -------------> eat(i.second,dist[i.second][0],2); rf=i.second; }else{ // <--------- // D | // --------------> eat(i.second,dist[rf][0]-dist[i.second][2],1); } } if (l.size()){ rf=l[0].second; eat(rf,dist[rrf][0]-dist[rf][1],1); l.erase(l.begin(),next(l.begin())); for (pair<int,int> i:l){ cerr<<i.first<<" "<<i.second<<" ??\n"; int dis,ps; dist[i.second][2]=get_distance(rf,i.second); assert(!((dist[i.second][2]+dist[rf][0]-dist[i.second][0])%2)); dis=(dist[i.second][2]+dist[rf][0]-dist[i.second][0])/2; ps=ans[rf].first+dis; if (ans[id[ps]].second==2){ // <--------------D // |---- ---- // <-------- eat(i.second,dist[rrf][0]-dist[i.second][1],1); rf=i.second; }else{ // <------------------D // | C ---- // --------> eat(i.second,ans[rf].first+dist[i.second][2],2); } } } int mn=ans[0].first-first; for (int i=0;i<n;i++){ location[i]=ans[i].first+mn; stype[i]=ans[i].second; } }

컴파일 시 표준 에러 (stderr) 메시지

rail.cpp: In function 'void find_location(int, int, int*, int*)':
rail.cpp:17:6: warning: unused variable 'q' [-Wunused-variable]
   17 |  int q=100000050;
      |      ^
/usr/bin/ld: /tmp/ccBI4RbA.o: in function `find_location(int, int, int*, int*)':
rail.cpp:(.text+0x775): undefined reference to `get_distance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0x8e1): undefined reference to `get_distance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0xa96): undefined reference to `get_distance(int, int)'
/usr/bin/ld: rail.cpp:(.text+0xc7e): undefined reference to `get_distance(int, int)'
/usr/bin/ld: /tmp/cc2faNEx.o: in function `main':
grader.cpp:(.text.startup+0x2d9): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status