Submission #806849

#TimeUsernameProblemLanguageResultExecution timeMemory
806849borisAngelovStations (IOI20_stations)C++17
0 / 100
3032 ms2097152 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int maxn = 1005; vector<int> g[maxn]; int tim = 0; int in[maxn]; int out[maxn]; void dfs(int node, int par) { in[node] = tim++; for (int i = 0; i < g[node].size(); ++i) { if (g[node][i] != par) { dfs(g[node][i], node); } } out[node] = tim - 1; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i = 0; i < u.size(); ++i) { int x = u[i]; int y = v[i]; g[x].push_back(y); g[y].push_back(x); } dfs(0, -1); vector<int> hashed; for (int i = 0; i < n; ++i) { hashed.push_back(in[i] * 1000 + out[i]); } return hashed; } int find_next_station(int s, int t, vector<int> c) { int in_s = s / 1000; int out_s = s % 1000; int in_t = t / 1000; int out_t = t % 1000; if (in_s <= in_t && out_t <= out_s) { int from = (in_s == 0 ? 0 : 1); for (int i = from; i < c.size(); ++i) { int in_i = c[i] / 1000; int out_i = c[i] % 1000; if (in_i <= in_t && out_t <= out_i) { return c[i]; } } } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int)':
stations.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < g[node].size(); ++i)
      |                     ~~^~~~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:31:23: 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 < u.size(); ++i)
      |                     ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:64:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         for (int i = from; i < c.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...