Submission #750386

#TimeUsernameProblemLanguageResultExecution timeMemory
750386mohav48173Stations (IOI20_stations)C++14
100 / 100
961 ms788 KiB
#include "stations.h"///15:49 #include<bits/stdc++.h> using namespace std; vector<int>cur; vector<int>a[1001]; int counter; void dfs(int n,int par=-1,int depth=0) { if(depth%2==0)cur[n]=counter++; for(int i:a[n]) { if(i!=par)dfs(i,n,depth+1); } if(depth%2==1)cur[n]=counter++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { cur=vector<int>(n,0); for(int i=0;i<n;i++){a[i].clear();} counter=0; for(int i=0;i<n-1;i++) { a[u[i]].push_back(v[i]); a[v[i]].push_back(u[i]); } dfs(0); return cur; } int find_next_station(int s, int t, vector<int> c) { if(c.size()==1)return c[0]; int par=-1; if(s<c[0])par=c[c.size()-1]; else par=c[0]; c.erase(find(c.begin(),c.end(),par)); if(par<s) { if(t>s || t<c[0])return par; for(int i=0;i<c.size();i++) { if(i==c.size()-1 || c[i+1]>t)return c[i]; } } else { if(t<s || t>c[c.size()-1])return par; for(int i=0;i<c.size();i++) { if(t<=c[i])return c[i]; } } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:34:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         for(int i=0;i<c.size();i++) {
      |                     ~^~~~~~~~~
stations.cpp:35:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if(i==c.size()-1 || c[i+1]>t)return c[i];
      |                ~^~~~~~~~~~~~
stations.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(int i=0;i<c.size();i++) {
      |                     ~^~~~~~~~~
stations.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
#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...