Submission #1073931

#TimeUsernameProblemLanguageResultExecution timeMemory
1073931LCJLYStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include "stations.h" #include "stub.cpp" //#include <bits/stdc++.h> using namespace std; #define show(x,y) cout << y << " " << #x << endl; #define show2(x,y,i,j) cout << y << " " << #x << " " << j << " " << #i << endl; #define show3(x,y,i,j,p,q) cout << y << " " << #x << " " << j << " " << #i << " " << q << " " << #p << endl; #define show4(x,y) for(auto it:y) cout << it << " "; cout << #x << endl; typedef pair<int,int>pii; vector<int>adj[1005]; bool visited[1005]; int d[1005]; vector<int>ans; int ptr=0; void dfs(int index, int par){ if(d[index]%2==0) ans[index]=ptr++; for(auto it:adj[index]){ if(it==par) continue; d[it]=d[index]+1; dfs(it,index); } if(d[index]%2==1) ans[index]=ptr++; } vector<int>label(int n, int k, vector<int>u, vector<int>v) { for(int x=0;x<=n;x++){ adj[x].clear(); visited[x]=0; d[x]=0; } ans.clear(); ans=vector<int>(n,0); ptr=0; for(int x=0;x<n-1;x++){ adj[u[x]].push_back(v[x]); adj[v[x]].push_back(u[x]); } dfs(0,-1); //show4(ans,ans); return ans; } int find_next_station(int s, int t, vector<int> c) { int maxi=0; for(auto it:c) maxi=max(maxi,it); vector<int>v; for(auto it:c) v.push_back(it); if(s>maxi){ //s is out sort(v.begin(),v.end()); int sz=v.size(); v.push_back(s); for(int x=1;x<sz;x++){ int l=v[x]; int r=v[x+1]-1; if(l<=t&&r>=t){ return v[x]; } } return v[0]; } else{ //s is in v.push_back(s-1); sort(v.begin(),v.end()); int sz=v.size(); for(int x=1;x<sz-1;x++){ int l=v[x-1]+1; int r=v[x]; if(l<=t&&r>=t){ return v[x]; } } return c.back(); } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:54:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   54 |   sort(v.begin(),v.end());
      |   ^~~~
      |   qsort
stations.cpp:69:3: error: 'sort' was not declared in this scope; did you mean 'qsort'?
   69 |   sort(v.begin(),v.end());
      |   ^~~~
      |   qsort