Submission #849278

#TimeUsernameProblemLanguageResultExecution timeMemory
849278IBoryStations (IOI20_stations)C++17
0 / 100
551 ms964 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int MAX = 1004; vector<int> G[MAX], ans; int in[MAX], out[MAX], dn; void DFS(int cur, int prev, int H) { in[cur] = dn++; for (int next : G[cur]) { if (next == prev) continue; DFS(next, cur, H + 1); } out[cur] = dn++; ans[cur] = ((H & 1) ? in[cur] : out[cur]); } vector<int> label(int N, int K, vector<int> U, vector<int> V) { for (int i = 0; i < N - 1; ++i) { G[U[i]].push_back(V[i]); G[V[i]].push_back(U[i]); } ans.resize(N); DFS(0, -1, 0); vector<int> T; for (int n : ans) T.push_back(n); sort(T.begin(), T.end()); for (int& n : ans) n = lower_bound(T.begin(), T.end(), n) - T.begin(); for (int i = 0; i < N; ++i) G[i].clear(); return ans; } int find_next_station(int S, int T, vector<int> C) { return 0; if (S == T) return S; sort(C.begin(), C.end()); if (T < S || C.back() < T) return C[0]; for (int i = 0; i < C.size(); ++i) { if (C[i] < S) continue; if (i + 1 == C.size() || T < C[i + 1]) return C[i]; } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:39:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for (int i = 0; i < C.size(); ++i) {
      |                  ~~^~~~~~~~~~
stations.cpp:41:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |   if (i + 1 == C.size() || T < C[i + 1]) return C[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...