Submission #614523

#TimeUsernameProblemLanguageResultExecution timeMemory
614523John3_141592Stations (IOI20_stations)C++14
0 / 100
2 ms692 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[u[i]].push_back(v[i]),grafo[v[i]].push_back(u[i]); int node; for(int i=1;i<=n;i++){ if(grafo[i].size()==1){ node=i; break; } } 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:11:14: warning: 'node' may be used uninitialized in this function [-Wmaybe-uninitialized]
   11 |     vis[node]=true,arr[node]=c;
      |     ~~~~~~~~~^~~~~
stations.cpp:19:6: note: 'node' was declared here
   19 |  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...