Submission #320466

#TimeUsernameProblemLanguageResultExecution timeMemory
320466Ambok기지국 (IOI20_stations)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int coun=0; vector <int> label(int n, int k, vector <int> u, vector <int> v) { vector < vector <int> > vec(n); vector <int> L(n); int s, h, i; void dfs (int s, int h); { if (h%2==0) L[s]=coun; coun++; for (int i=0; i<vec[s].size(); i++) dfs(vec[s][i], h+1); if (h%2==1) L[s]=coun; h--; coun++; } for (i=0; i<n; i++) { vec[u[i]].push_back(v[i]); } L[0]=0; dfs (0, 0); return L; } int find_next_station(int s, int t, vector <int>c) { int n=c.size(), i; int in[n+1], out[n+1]; if (s>c[n-1]) { in[n]=c[1]-1; out[n]=s; for (i=0; i<n; i++) in[i]=c[i]; for (i=1; i<n; i++) { out[i]=in[i+1]-1; } if (t>in[n] && t<out[n]) { for (i=1; i<n; i++) { if (t>=in[i] && t<=out[i]) return c[i]; } } else return c[0]; } else { in[n]=s; out[n]=c[n-2]+1; for (i=0; i<n; i++) out[i]=c[i]; in[0]=s+1; for (i=1; i<n; i++) { in[i]=out[i-1]+1; } if (t>in[n] && t<out[n]) { for (i=0; i<n-1; i++) { if (t>=in[i] && t<=out[i]) return c[i]; } } else return c[n-1]; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:14:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |   for (int i=0; i<vec[s].size(); i++)
      |                 ~^~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:78:1: warning: control reaches end of non-void function [-Wreturn-type]
   78 | }
      | ^
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:12:10: warning: 'h' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |   if (h%2==0) L[s]=coun;
      |       ~~~^~~
stations.cpp:12:18: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   12 |   if (h%2==0) L[s]=coun;
      |                  ^
/tmp/cc5v6BvH.o: In function `label(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
stations.cpp:(.text+0x317): undefined reference to `dfs(int, int)'
stations.cpp:(.text+0x3c3): undefined reference to `dfs(int, int)'
collect2: error: ld returned 1 exit status