Submission #314301

#TimeUsernameProblemLanguageResultExecution timeMemory
314301DanerZeinStations (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include "stations.h" #include <vector> #include <bits/stdc++.h> #define MAX 1000000000 using namespace std; typedef vector<int> vi; typedef pair<int,int> ii; vector<int> labels; int in[1010],out[1010]; int it=0; void dfs(int u){ it++; in[u]=it; for(auto &v:G[u]){ if(!in[u]){ dfs(v); } } it++; out[u]=it; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { labels.assign(n,-1); G.clear(); G.resize(n+1); int t=u.size(); for(int i=0;i<t;i++){ int x=u[i],y=v[i]; G[x].push_back(y); G[y].push_back(x); } for(int i=0;i<n;i++){ int la=in[i]*1000; la+=out[i]; labels[i]=la; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { int ro=-1,rp=-1; int si,ti,so,to; si=s/1000; so=s%1000; ti=t/1000; to=s%1000; bool sub=0; if(si<ti && so>to){ int ia,oa; for(int i=0;i<c.size();i++){ ia=c[i]/1000; oa=c[i]%1000; if(ia<ti && oa>to){ // a que subarbol pertenece t rp=c[i]; break; } } return rp; } else{ int ia,oa; for(int i=0;i<c.size();i++){ ia=c[i]/1000; oa=c[i]%1000; if(!(ia<ti && oa>to)){ // si no es mi hijo es mi padre ro=c[i]; break; } } return ro; } }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int)':
stations.cpp:14:15: error: 'G' was not declared in this scope
   14 |   for(auto &v:G[u]){
      |               ^
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:24:3: error: 'G' was not declared in this scope
   24 |   G.clear();
      |   ^
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i=0;i<c.size();i++){
      |                 ~^~~~~~~~~
stations.cpp:59:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0;i<c.size();i++){
      |                 ~^~~~~~~~~
stations.cpp:45:8: warning: unused variable 'sub' [-Wunused-variable]
   45 |   bool sub=0;
      |        ^~~