Submission #432856

#TimeUsernameProblemLanguageResultExecution timeMemory
432856EnkognitStations (IOI20_stations)C++14
0 / 100
3057 ms2097156 KiB
#include <bits/stdc++.h> #include "stations.h" #include <vector> #define ll long long #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; vector<ll> c[1005]; ll T; ll in[1005], out[1005], pp[1005]; void dfs(int h,int p=-1) { pp[h]=p; in[h]=++T; for (int i = 0; i < c[h].size(); i++) if (c[h][i]!=p) { dfs(c[h][i], h); } out[h]=++T; } bool is_ancestor(int x,int y) { return in[x]<=in[y] && out[x]>=out[y]; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); for (int i = 0; i < n; i++) { labels[i] = i; } for (int i = 0; i < n-1; i++) { c[u[i]].pb(v[i]); c[v[i]].pb(u[i]); } dfs(0); return labels; } int find_next_station(int s, int t, std::vector<int> cc) { if (!is_ancestor(s, t)) return pp[s]; for (int i = 0; i < c[s].size(); i++) if (is_ancestor(c[s][i], t) && pp[s]!=c[s][i]) return c[s][i]; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:22:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i = 0; i < c[h].size(); i++)
      |                     ~~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:56:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for (int i = 0; i < c[s].size(); i++)
      |                     ~~^~~~~~~~~~~~~
stations.cpp:58:1: warning: control reaches end of non-void function [-Wreturn-type]
   58 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...