Submission #432842

#TimeUsernameProblemLanguageResultExecution timeMemory
432842charterlaStations (IOI20_stations)C++14
100 / 100
898 ms796 KiB
#include "stations.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; struct Node{ vector<int> to; }point[1005]; vector<int> labels; int num; void build(int now,int last,int p){ if(p%2==0)labels[now]=num++; for(int i=0;i<point[now].to.size();i++){ int next=point[now].to[i]; if(next!=last)build(next,now,p+1); } if(p%2==1)labels[now]=num++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { num=0;labels.clear();labels.resize(n); for(int i=0;i<n;i++){point[i].to.clear();} for(int i=0;i<n-1;i++){ point[u[i]].to.push_back(v[i]); point[v[i]].to.push_back(u[i]); } build(0,-1,0); //for(int i=0;i<n;i++)cout<<i<<":"<<labels[i]<<" ";cout<<endl; return labels; } int find_next_station(int s, int t, vector<int> c){ if(c.size()==1)return c[0]; if(s>c[0]){ if(t<=c[0] || t>s)return c[0]; else return *--upper_bound(c.begin(),c.end(),t); } else{ if(t<s || t>=c.back())return c.back(); else return *lower_bound(c.begin(),c.end(),t); } }

Compilation message (stderr)

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