Submission #616185

#TimeUsernameProblemLanguageResultExecution timeMemory
616185John3_141592Stations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector <int> grafo[1003]; map <int,bool> mapa; int arr[1003]; bool vis[1003]; void dfs1(int node,int c){ vis[node]=true,arr[node]=c; for(auto i:grafo[node]) if(!vis[i]) dfs1(i,c+1); } void dfs2(int node,int c){ vis[node]=true,arr[node]=c; for(auto i:grafo[node]) if(!vis[i]) dfs2(i,c-1); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { if(n==2){ vector <int> vec; vec.push_back(0); vec.push_back(1); return vec; } mapa.clear(); for(int i=0;i<n;i++) grafo[i].clear(); for(int i=0;i<n-1;i++){ grafo[u[i]].push_back(v[i]); grafo[v[i]].push_back(u[i]); } int a=-1,b=-1,c=-1; for(int i=0;i<n;i++){ if(grafo[i].size()==1){ if(a==-1) a=i; else b=i; } if(grafo[i].size()>2) c=i; } if(c==-1) c=grafo[a][0]; else{ for(auto i:grafo[c]) mapa[i]=true; a=-1,b=-1; for(int i=0;i<n;i++){ if(grafo[i].size()==1 && !mapa.count(i)){ if(a==-1) a=i; else b=i; } } if(a==-1){ for(auto i:grafo[c]){ if(grafo[i].size()!=1) continue; if(a==-1) a=i; else b=i; } } else if(b==-1){ for(auto i:grafo[c]){ if(grafo[i].size()!=1) continue; if(b==-1) b=i; } } } fill(arr,arr+n+1,0); fill(vis,vis+n+1,false); vis[c]=true; int aux=0; dfs1(a,0); for(int i=0;i<n;i++) if(vis[i] && i!=c) aux++; dfs2(b,n-1); arr[c]=aux++; for(int i=0;i<n;i++) if(!vis[i]) arr[i]=aux++; vector <int> solve; for(int i=0;i<n;i++) solve.push_back(arr[i]); return solve; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccNKKGOH.o: in function `main':
stub.cpp:(.text.startup+0x4cc): undefined reference to `find_next_station(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status