Submission #826620

#TimeUsernameProblemLanguageResultExecution timeMemory
826620Marco_EscandonStations (IOI20_stations)C++17
0 / 100
733 ms696 KiB
#include <vector> #include <bits/stdc++.h> using namespace std; typedef long long ll; ll vis=0; vector<int> sol; vector<vector<ll>> cad; 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) { cad.assign(n+5,vector<ll>()); for(int i=0; i<u.size(); i++) { cad[u[i]].push_back(v[i]); cad[v[i]].push_back(u[i]); } sol.clear();; sol.assign(n,0); dfs(0,-1,2); return sol; } int find_next_station(int s, int t, std::vector<int> c) { return 0; 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:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0; i<u.size(); i++)
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:56:23: 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=0; i<c.size()-1; i++)
      |                      ~^~~~~~~~~~~
stations.cpp:68:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         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...