Submission #305319

#TimeUsernameProblemLanguageResultExecution timeMemory
305319FdgStations (IOI20_stations)C++14
100 / 100
1117 ms1136 KiB
#include <iostream> #include <vector> #include <map> #include <set> #include <algorithm> #include <memory.h> using namespace std; vector<int> g[1002]; vector<int> color; bool used[1002]; int ptr; void dfs(int v, bool markFirst) { used[v] = true; if (markFirst) color[v] = ptr++; for (int x : g[v]) if (!used[x]) dfs(x, !markFirst); if (!markFirst) color[v] = ptr++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n; ++i) g[i].clear(); for (int i = 0; i < u.size(); ++i) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } ptr = 0; color.resize(n, -1); memset(used, false, sizeof(used)); dfs(0, true); return color; } int find_next_station(int s, int t, vector<int> st) { sort(st.begin(), st.end()); if (s < st[0]) { if (t < s) return st.back(); for (int x : st) if (t <= x) return x; return st.back(); } else { if (t > s) return st[0]; for (int i = st.size() - 1; i >= 0; --i) if (st[i] <= t) return st[i]; return st[0]; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for (int i = 0; i < u.size(); ++i) {
      |                   ~~^~~~~~~~~~
#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...