Submission #321954

#TimeUsernameProblemLanguageResultExecution timeMemory
321954katearimaStations (IOI20_stations)C++14
5 / 100
1140 ms56280 KiB
#include "stations.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int N=1005; vector<vector<int>> a(N); vector<int> ans(N); int i,n,k,m,x,j,t; void DFS(vector<vector<int>> a, int x,int y,int d){ if(d%2==0) {ans[y]=t; t++;} for(int i=0; i<a[y].size(); i++){ if(a[y][i]==x) continue; DFS(a,y,a[y][i],d+1); } if(d%2!=0) {ans[y]=t; t++;} } vector<int> label(int n, int k, vector<int> u, vector<int> v) { vector<int> label(n); for(i=0; i<n; i++){ a[i].clear(); ans[i]=0; } for(i=0; i<n-1; i++){ a[u[i]].push_back(v[i]); a[v[i]].push_back(u[i]); } t=0; DFS(a,-1,0,0); /*for(i=0; i<n; i++){ cout<<ans[i]<<endl; }*/ for(i=0; i<n; i++) label[i]=ans[i]; //ans.clear(); a.clear(); return label; } int find_next_station(int s, int t, vector<int> c) { bool parent=true; int ans; if(s<c[0]){ c.insert(c.begin(),s); for(int i=1; i<c.size()-1; i++){ if(t<=c[i] && t>=c[i-1]+1) return c[i]; } return c[c.size()-1]; } else{ c.push_back(s); for(int i=1; i<c.size()-1; i++){ if(t>=c[i] && t<=c[i+1]-1) return c[i]; return c[0]; } } //cout<<"ans"<<ans<<endl; //if(ans==s) return c[0]; }

Compilation message (stderr)

stations.cpp: In function 'void DFS(std::vector<std::vector<int> >, int, int, int)':
stations.cpp:11:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |  for(int i=0; i<a[y].size(); i++){
      |               ~^~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:44:17: 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=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:51:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |   for(int i=1; i<c.size()-1; i++){
      |                ~^~~~~~~~~~~
stations.cpp:39:7: warning: unused variable 'parent' [-Wunused-variable]
   39 |  bool parent=true;
      |       ^~~~~~
stations.cpp:40:6: warning: unused variable 'ans' [-Wunused-variable]
   40 |  int ans;
      |      ^~~
#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...