Submission #1085300

#TimeUsernameProblemLanguageResultExecution timeMemory
10853004QT0RStations (IOI20_stations)C++17
0 / 100
3062 ms2097152 KiB
#include <bits/stdc++.h> using namespace std; vector<int> graph[1002]; int dep[1002]; int timer; int pre[1002]; int post[1002]; void dfs(int v, int p){ pre[v]=timer++; for (auto u : graph[v]){ if (u==p)continue; dep[u]=dep[v]+1; dfs(u,v); } post[v]=timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ 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); int iter=0; set<int> s; map<int,int> mp; for (int i = 0; i<n; i++)s.insert(dep[i]&1?post[i]:pre[i]); for (auto x : s)mp[x]=iter++; vector<int> ans(n); for (int i = 0; i<n; i++){ ans[i]=mp[dep[i]&1?post[i]:pre[i]]; } return ans; } int find_next_station(int s, int t, vector<int> c){ int cas=1; for (auto u : c)if (s<u)cas=0; if (cas){ int fat=c[0]; c.erase(c.begin()); int prv=s; for (int i = c.size()-1; i>=0; i--){ if (c[i]<=t && t<prv)return c[i]; prv=c[i]; } return fat; } else{ int fat=c.back(); c.pop_back(); int prv=s; for (int i = 0; i<c.size(); i++){ if (prv<t && t<=c[i])return c[i]; prv=c[i]; } return fat; } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |   for (int i = 0; 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...