Submission #826604

#TimeUsernameProblemLanguageResultExecution timeMemory
826604Marco_EscandonStations (IOI20_stations)C++17
0 / 100
3049 ms2097152 KiB
#include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; ll vis=0; vector<int> sol; vector<ll> cad[10000]; void dfs(ll node,ll p, ll p2) { if(p2%2==0) { sol[node]=vis; vis++; } for(auto i:cad[node]) { if(i!=p) { dfs(i,node,p2+1); } } if(p2%2==1) { sol[node]=vis; vis++; } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { for(int i=0; i<u.size(); i++) { cad[u[i]].push_back(v[i]); cad[v[i]].push_back(u[i]); } sol.resize(n); dfs(0,-1,0); return sol; } int find_next_station(int s, int t, std::vector<int> c) { sort(c.begin(), c.end()); if(c.size()==1)return c[0]; ll pl=0; for(auto i:c) { if(i>s) pl++; } if(pl==0) { if(c[0]>=t||s<t) return c[0]; for(int i=0; i<c.size()-1; i++) { if(c[i]<=t&&c[i+1]>=t) return c[i+1]; } return c[0]; } else { if(c.back()<=t||t<s) return c.back(); for(int i=0; i<c.size(); i++) { if(c[i]>=t) return c[i]; } return c.back(); } }

Compilation message (stderr)

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