Submission #311959

#TimeUsernameProblemLanguageResultExecution timeMemory
311959tzxydbyStations (IOI20_stations)C++14
0 / 100
876 ms768 KiB
#include"stations.h" #include<bits/stdc++.h> using namespace std; const int N=1005; vector<int>e[N],a; int c; void dfs(int u,int f,int d) { if(d) a[u]=c++; for(auto v:e[u]) if(v!=f) dfs(v,u,d^1); if(!d) a[u]=c++; } vector<int> label(int n,int k,vector<int>u,vector<int>v) { a.assign(n,0); for(int i=0;i<n;i++) e[i].clear(); c=0; for(int i=0;i<n-2;i++) { e[u[i]].push_back(v[i]); e[v[i]].push_back(u[i]); } dfs(0,0,0); a[0]=1000; return a; } int find_next_station(int s,int t,vector<int>c) { if(c.size()==1) return c[0]; if(s==1000) { for(int i=0;i<c.size()-1;i++) if(c[i]<=t&&t<c[i+1]) return c[i]; return c.back(); } else if(s>c.back()) { for(int i=1;i<c.size()-1;i++) if(c[i]<=t&&t<c[i+1]) return c[i]; if(c.back()<=t&&t<s) return c.back(); return c[0]; } else { if(s<t&&t<=c[0]) return c[0]; for(int i=1;i<c.size()-1;i++) if(c[i-1]<t&&t<=c[i]) return c[i]; return c.back(); } }

Compilation message (stderr)

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