Submission #350805

#TimeUsernameProblemLanguageResultExecution timeMemory
350805juggernautStations (IOI20_stations)C++14
100 / 100
1071 ms1292 KiB
#include"stations.h" #include<bits/stdc++.h> using namespace std; #ifndef EVAL #include"stub.cpp" #endif vector<int>gr[1005]; vector<int>order; int tiktak; int tin[1005],tout[1005]; void dfs(int v,int p=-1,bool h=0){ if(!h){ tin[v]=tiktak++; order[v]=tin[v]; } for(int to:gr[v]){ if(to==p)continue; dfs(to,v,h^1); } if(h){ tout[v]=tiktak++; order[v]=tout[v]; } } vector<int>label(int n,int k,vector<int>u,vector<int>v){ order.resize(n); for(int i=0;i<n-1;i++){ gr[u[i]].push_back(v[i]); gr[v[i]].push_back(u[i]); } dfs(0); for(int i=0;i<n;i++)gr[i].clear(); tiktak=0; return order; } int find_next_station(int s,int t,vector<int>c){ if(c.size()==1)return c[0]; int x,y; if(s<c[0]){//tin[v] x=s; if(s==0)y=c[c.size()-1]; else y=c[c.size()-2]; if(t<x||t>y)return c.back(); for(int i=0;i<c.size();i++)if(t<=c[i])return c[i]; }else{//tout[s] x=c[1]-1; if(t<x||t>s)return c[0]; for(int i=c.size()-1;i>=1;i--)if(c[i]<=t)return c[i]; } }

Compilation message (stderr)

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