Submission #1080213

#TimeUsernameProblemLanguageResultExecution timeMemory
1080213UmairAhmadMirzaStations (IOI20_stations)C++17
52.32 / 100
676 ms1176 KiB
#include <bits/stdc++.h> using namespace std; int const N=1005; vector<int> adj[N]; int tim=-1; int in[N],out[N]; int lab[N]; void dfs(int node,int par=-1){ tim++; in[node]=tim; for(int i:adj[node]) if(i!=par) dfs(i,node); out[node]=tim; } vector<int> solver(int n){ for(int i=0;i<n;i++) if(adj[i].size()==1){ dfs(i); break; } vector<int> val; for (int i = 0; i < n; ++i) val.push_back(in[i]); return val; } vector<int> label(int n, int k, vector<int> u, vector<int> v){ for (int i = 0; i < n; ++i) { adj[i].clear(); tim=-1; in[i]=out[i]=0; } for (int i = 0; i < n-1; ++i) { adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } if(k<=1000) return solver(n); dfs(0); vector<int> val; for (int i = 0; i < n; ++i) val.push_back((in[i]*1000)+out[i]); // for(int i=0;i<n;i++) // cout<<val[i]<<' '; // cout<<endl; return val; } int fns(int s,int t,vector<int> c){ if(c.size()==0) return c[0]; if(c[0]>c[1]) swap(c[0],c[1]); if(t<=c[0]) return c[0]; return c[1]; } int find_next_station(int s, int t, vector<int> c){ bool b=(s>1000 || t>1000); for(int i=0;i<c.size();i++) if(c[i]>1000) b=1; if(b==0) return fns(s,t,c); // cout<<s<<' '<<t<<endl; int n=c.size(); int inn[n],outt[n]; int ti=t/1000,to=t%1000; for (int i = 0; i < n; ++i) { inn[i]=c[i]/1000; outt[i]=c[i]%1000; } int si=s/1000,so=s%1000; for(int i=0;i<n;i++) if(inn[i]<=ti && to<=outt[i] && !(inn[i]<=si && so<=outt[i])) return c[i]; for(int i=0;i<n;i++) if(inn[i]<=si && so<=outt[i]) return c[i]; return 0; }

Compilation message (stderr)

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