Submission #555364

#TimeUsernameProblemLanguageResultExecution timeMemory
555364ITOStations (IOI20_stations)C++17
100 / 100
775 ms768 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> e[1000], lab; int co; void df(int no, int pa, bool pr) { if (pr) lab[no] = co++; for (int ed : e[no]) { if (ed != pa) df(ed, no, !pr); } if (!pr) lab[no] = co++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { co = 0; lab.resize(n); for (int i = 0; i < n; i++) e[i].clear(); for (int i = 0; i < n - 1; i++) { e[u[i]].push_back(v[i]); e[v[i]].push_back(u[i]); } df(0, 0, 1); return lab; } int find_next_station(int s, int t, std::vector<int> c) { if (c[0] < s) { if (t < c[0] || t > s) return c[0]; for (int i = c.size() - 1; i >= 0; i--) if (c[i] <= t) return c[i]; } else { if (t > c.back() || t < s) return c.back(); for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i]; } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for (int i = 0; i < c.size(); i++) if (c[i] >= t) return c[i];
      |                   ~~^~~~~~~~~~
stations.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
   33 | }
      | ^
#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...