Submission #815908

#TimeUsernameProblemLanguageResultExecution timeMemory
815908math_rabbit_1028Stations (IOI20_stations)C++14
0 / 100
1 ms336 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<int> adj[1010]; int ch[1010], ord[2020], lt[2020], rt[2020], dep[2020]; int r = -1; void DFS(int v) { ord[++r] = v; lt[v] = r; for (int i = 0; i < adj[v].size(); i++) { int next = adj[v][i]; if (ch[next]) continue; ch[next] = 1; dep[next] = dep[v] + 1; DFS(next); ord[++r] = v; } rt[v] = r; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < n - 1; i++) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++) ch[i] = 0; ch[0] = 1; dep[0] = 0; DFS(0); vector<int> lab(n); for (int i = 0; i < n; i++) { if (dep[i] % 2 == 0) lab[i] = lt[i]; else lab[i] = rt[i]; } for (int i = 0; i < n; i++) cout << lab[i] << " "; cout << "\n"; return lab; } int find_next_station(int s, int t, vector<int> c) { if (s < c[0]) { for (int i = 0; i < c.size(); i++) { int l = ((i == 0) ? s : c[i - 1]), r = c[i]; if (l < t && t <= r) return c[i]; } return c[c.size() - 1]; } if (s > c[c.size() - 1]) { for (int i = c.size() - 1; i >= 0; i--) { int l = c[i], r = ((i == c.size() - 1) ? s : c[i + 1]); if (l <= t && t < r) return c[i]; } return c[0]; } }

Compilation message (stderr)

stations.cpp: In function 'void DFS(int)':
stations.cpp:12:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for (int i = 0; i < adj[v].size(); i++) {
      |                  ~~^~~~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:48:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |   for (int i = 0; i < c.size(); i++) {
      |                   ~~^~~~~~~~~~
stations.cpp:56:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |    int l = c[i], r = ((i == c.size() - 1) ? s : c[i + 1]);
      |                        ~~^~~~~~~~~~~~~~~
stations.cpp:61:1: warning: control reaches end of non-void function [-Wreturn-type]
   61 | }
      | ^
#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...