제출 #945757

#제출 시각아이디문제언어결과실행 시간메모리
945757WongChun1234철로 (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; 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]=getDistance(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]=getDistance(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]=getDistance(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]=getDistance(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:16:6: warning: unused variable 'q' [-Wunused-variable]
   16 |  int q=100000050;
      |      ^
/usr/bin/ld: /tmp/cc88Cit3.o: in function `main':
grader.cpp:(.text.startup+0x2d9): undefined reference to `findLocation'
collect2: error: ld returned 1 exit status