Submission #768092

#TimeUsernameProblemLanguageResultExecution timeMemory
7680923RR0R404Stations (IOI20_stations)C++14
0 / 100
1 ms556 KiB
#include <bits/stdc++.h> using namespace std; vector<int> child(1000,0); int l=0; set<int> visited; int dfs(int node,int d,vector<int> L,vector<vector<int>> adj) { visited.insert(node); L[node] = l; l++; int b=0; for(auto p: adj[node]) { if(visited.find(p)==visited.end()) { continue; } child[d] += dfs(p,l,L,adj); } return child[d]+1; } vector<int> label(int n,int k,vector<int> u,vector<int> v) { vector<vector<int>> adj(n); for(int i=0;i<n-1,i++;) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } vector<int> L(n,0); for(auto i: adj) { if(i.size() == 1); { dfs(i[0],0,L,adj); } break; } return L; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(),c.end()); if(s+child[s]<t) { return c[0]; } if(s>t) { return c[0]; } return *(upper_bound(c.begin(),c.end(),t)-1); }

Compilation message (stderr)

stations.cpp: In function 'int dfs(int, int, std::vector<int>, std::vector<std::vector<int> >)':
stations.cpp:11:9: warning: unused variable 'b' [-Wunused-variable]
   11 |     int b=0;
      |         ^
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:18: warning: left operand of comma operator has no effect [-Wunused-value]
   25 |     for(int i=0;i<n-1,i++;)
      |                 ~^~~~
stations.cpp:34:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   34 |         if(i.size() == 1);
      |         ^~
stations.cpp:35:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   35 |         {
      |         ^
#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...