Submission #616077

#TimeUsernameProblemLanguageResultExecution timeMemory
616077John3_141592Stations (IOI20_stations)C++14
5 / 100
998 ms664 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; int arr[1003]; vector <int> grafo[1003]; bool vis[1003]; void dfs(int node,int c){ vis[node]=true,arr[node]=c; for(auto i:grafo[node]) if(!vis[i]) dfs(i,c+1); } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { 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 node; for(int i=0;i<n;i++){ if(grafo[i].size()==1){ node=i; break; } } fill(vis,vis+n+5,0); fill(arr,arr+n+5,0); dfs(node,0); vector <int> solve; for(int i=0;i<n;i++) solve.push_back(arr[i]); return solve; } int find_next_station(int s, int t, std::vector<int> c) { if(c.size()==1) return c[0]; if(s<t) return c[1]; return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:18:6: warning: 'node' may be used uninitialized in this function [-Wmaybe-uninitialized]
   18 |  int node;
      |      ^~~~
#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...