제출 #719106

#제출 시각아이디문제언어결과실행 시간메모리
719106bin9638철로 (IOI14_rail)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #ifndef SKY #include "rail.h" #endif // SKY using namespace std; #define N 5010 #define ll long long #define fs first #define sc second #define ii pair<int,int> #define pb push_back #define iii pair<int,pair<int,int>> int dis[N][N],n; #ifdef SKY int pos[N],type[N],location[N],stype[N]; int getDistance(int u,int v) { if(pos[u]>pos[v]) swap(u,v); if(u==v) return 0; int L=-1,R=-1; for(int i=0;i<n;i++) if(type[i]==0&&pos[i]<=pos[u]&&(L==-1||pos[i]>pos[L])) L=i; for(int i=0;i<n;i++) if(type[i]==1&&pos[i]>=pos[v]&&(R==-1||pos[i]<pos[R])) R=i; return pos[R]-pos[L]+(pos[u]-pos[L])+(pos[R]-pos[v]); } #endif // SKY int my_ask(int u,int v) { if(u==v) return 0; if(dis[u][v]!=-1) return dis[u][v]; dis[u][v]=dis[v][u]=getDistance(u,v); return dis[u][v]; } void solve(vector<int>s,int moc,int val) { while(!s.empty()) { vector<int>luu; int u=-1; for(auto i:s) if(u==-1||my_ask(i,moc)<my_ask(u,moc)) u=i; if(val==0) location[u]=location[moc]-my_ask(u,moc); else location[u]=location[moc]+my_ask(u,moc); stype[u]=val; for(auto i:s) if(i!=u) { if(my_ask(moc,i)==my_ask(moc,u)+my_ask(u,i)) { location[i]=(val==0 ? location[u]+my_ask(u,i) : location[u]-my_ask(u,i)); stype[i]=(val^1); }else { luu.pb(i); } } s=luu; } } void findLocation(int cc, int first, int location_ans[], int stype_ans[]) { n=cc; memset(dis,-1,sizeof(dis)); location[0]=first; stype[0]=0; int R=-1; for(int i=1;i<n;i++) if(R==-1||my_ask(i,0)<my_ask(R,0)) R=i; location[R]=location[0]+my_ask(R,0); stype[R]=1; int L=-1; for(int i=0;i<n;i++) if(i!=R&&(L==-1||my_ask(i,R)<my_ask(L,R))) L=i; location[L]=location[R]-my_ask(L,R); stype[L]=0; //cout<<L<<" "<<R<<endl; vector<int>lis_left,list_right; for(int i=0;i<n;i++) if(i!=L&&i!=R) { if(my_ask(i,L)>my_ask(i,R)) lis_left.pb(i); else list_right.pb(i); } solve(lis_left,R,0); solve(list_right,L,1); for(int i=0;i<n;i++) { stype[i]++; location_ans[i]=location[i]; stype_ans[i]=stype[i]; } #ifdef SKY for(int i=0;i<n;i++) cout<<location[i]<<" "<<stype[i]<<endl; #endif // SKY } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); int n; cin>>n; for(int i=0;i<n;i++) cin>>pos[i]>>type[i]; int location[n],stype[n]; findLocation(n,pos[0],location,stype); return 0; } #endif

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

rail.cpp: In function 'void solve(std::vector<int>, int, int)':
rail.cpp:58:13: error: 'location' was not declared in this scope; did you mean 'localtime'?
   58 |             location[u]=location[moc]-my_ask(u,moc);
      |             ^~~~~~~~
      |             localtime
rail.cpp:59:22: error: 'location' was not declared in this scope; did you mean 'localtime'?
   59 |                 else location[u]=location[moc]+my_ask(u,moc);
      |                      ^~~~~~~~
      |                      localtime
rail.cpp:60:9: error: 'stype' was not declared in this scope; did you mean 'wctype'?
   60 |         stype[u]=val;
      |         ^~~~~
      |         wctype
rail.cpp:66:21: error: 'location' was not declared in this scope; did you mean 'localtime'?
   66 |                     location[i]=(val==0 ? location[u]+my_ask(u,i) : location[u]-my_ask(u,i));
      |                     ^~~~~~~~
      |                     localtime
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:81:5: error: 'location' was not declared in this scope; did you mean 'localtime'?
   81 |     location[0]=first;
      |     ^~~~~~~~
      |     localtime
rail.cpp:82:5: error: 'stype' was not declared in this scope; did you mean 'wctype'?
   82 |     stype[0]=0;
      |     ^~~~~
      |     wctype