Submission #580918

#TimeUsernameProblemLanguageResultExecution timeMemory
580918JomnoiStations (IOI20_stations)C++17
52.32 / 100
1039 ms832 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; const int MAX_N = 1005; int N, timer; vector <int> graph[MAX_N]; int st[MAX_N], en[MAX_N]; void init(int n) { N = n, timer = 0; for(int i = 0; i < N; i++) { st[i] = en[i] = 0; graph[i].clear(); } } void dfs(int u, int p) { st[u] = timer++; for(auto v : graph[u]) { if(v != p) { dfs(v, u); } } en[u] = timer - 1; } vector <int> label(int n, int k, vector <int> u, vector <int> v) { init(n); for(int i = 0; i < N - 1; i++) { graph[u[i]].push_back(v[i]); graph[v[i]].push_back(u[i]); } dfs(0, -1); vector <int> labels(N); for(int i = 0; i < N; i++) { labels[i] = st[i] * 1000 + en[i]; } return labels; } int find_next_station(int s, int t, vector <int> c) { int stS = s / 1000, enS = s % 1000; int stT = t / 1000, enT = t % 1000; for(int i = 1; i < c.size(); i++) { int stC = c[i] / 1000, enC = c[i] % 1000; if(stC <= stT and enT <= enC) { return c[i]; } } return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |  for(int i = 1; i < c.size(); i++) {
      |                 ~~^~~~~~~~~~
stations.cpp:47:6: warning: unused variable 'stS' [-Wunused-variable]
   47 |  int stS = s / 1000, enS = s % 1000;
      |      ^~~
stations.cpp:47:22: warning: unused variable 'enS' [-Wunused-variable]
   47 |  int stS = s / 1000, enS = s % 1000;
      |                      ^~~
#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...