Submission #795885

#TimeUsernameProblemLanguageResultExecution timeMemory
795885BT21tataStations (IOI20_stations)C++17
100 / 100
780 ms848 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; int cur; vector<int> g[1005], labels; void dfs(int v, int p, int x) { if(!x) labels[v]=cur++; for(int u : g[v]) { if(u==p) continue; dfs(u, v, x^1); } if(x) labels[v]=cur++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.resize(n, 0); for(int i=0; i<n; i++) g[i].clear(); cur=0; for(int i=0; i<u.size(); i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0, -1, 0); /*for(int u :labels) cout<<u<<' '; cout<<flush;*/ return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(), c.end()); if(s<c[0]) { int fs=s; for(int i=0; i<c.size()-1; i++) { if(fs<=t and t<=c[i]) return c[i]; fs=c[i]+1; } return c.back(); } else { int last=s; for(int i=c.size()-1; i>0; i--) { if(c[i]<=t and t<=last) return c[i]; last=c[i]-1; } return c[0]; } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i=0; i<u.size(); i++)
      |               ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for(int i=0; i<c.size()-1; 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...