Submission #985411

#TimeUsernameProblemLanguageResultExecution timeMemory
985411FZ_MeloStations (IOI20_stations)C++14
52.32 / 100
634 ms1476 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; int tam[1001]; void dfs(int node, int ant, vector<int> &labels, int &num){ labels[node]=num; num++; tam[node]=0; for(int h: adj[node]){ if(h==ant) continue; dfs(h, node, labels, num); tam[node]+=tam[h]+1; } labels[node]*=1000; labels[node]+=tam[node]; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vector<int> labels(n); adj.clear(); adj.resize(n+1); int num=0; for(int i=0; i<n-1; i++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } dfs(0, 0, labels, num); return labels; } int find_next_station(int s, int t, std::vector<int> c) { int x=s/1000; int sub=s-(x*1000); if(t/1000>x+sub || t/1000<x){ for(int i=0; i<c.size(); i++){ if(x>c[i]/1000) return c[i]; } } else{ for(int i=0; i<c.size(); i++){ if(c[i]/1000<x || c[i]/1000>t/1000) continue; int id=c[i]/1000; int cnt=c[i]-(id*1000); if(t/1000<=id+cnt) return c[i]; } } }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:39:17: 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:45:17: 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=0; i<c.size(); i++){
      |                ~^~~~~~~~~
stations.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
   54 | }
      | ^
#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...