Submission #719108

#TimeUsernameProblemLanguageResultExecution timeMemory
719108bin9638Rail (IOI14_rail)C++17
Compilation error
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],my_location[N],my_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) my_location[u]=my_location[moc]-my_ask(u,moc); else my_location[u]=my_location[moc]+my_ask(u,moc); my_stype[u]=val; for(auto i:s) if(i!=u) { if(my_ask(moc,i)==my_ask(moc,u)+my_ask(u,i)) { my_location[i]=(val==0 ? my_location[u]+my_ask(u,i) : my_location[u]-my_ask(u,i)); my_stype[i]=(val^1); }else { luu.pb(i); } } s=luu; } } void findLocation(int cc, int first, int location[], int stype[]) { n=cc; memset(dis,-1,sizeof(dis)); my_location[0]=first; my_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; my_location[R]=my_location[0]+my_ask(R,0); my_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; my_location[L]=my_location[R]-my_ask(L,R); my_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++) { my_stype[i]++; location[i]=my_location[i]; stype[i]=my_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

Compilation message (stderr)

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