Submission #420316

#TimeUsernameProblemLanguageResultExecution timeMemory
420316NintsiChkhaidzeStations (IOI20_stations)C++14
0 / 100
1190 ms640 KiB
#include "stations.h" #include <bits/stdc++.h> #define pb push_back using namespace std; vector <int> vec[1005],labels; int cnt = 0,in[1005],out[1005]; void dfs(int x,int p,int t){ in[x] = cnt++; if (t%2) labels[x] = in[x]; for (int j=0;j<vec[x].size();j++){ int to = vec[x][j]; if (to == p) continue; dfs(to,x,t + 1); } out[x] = cnt++; if (!labels[x]) labels[x] = out[x]; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { for (int i=0;i<1001;i++){ vec[i].clear(); in[i] = out[i] = 0; } for (int i=0;i<u.size();i++){ vec[u[i]].pb(v[i]); vec[v[i]].pb(u[i]); } cnt=0; labels.clear(); for (int i=0;i<n;i++) labels.pb(0); dfs(0,0,0); return labels; } int find_next_station(int s, int t, vector<int> c) { sort(c.begin(),c.end()); if (s > c[0]){ //s - out for (int i = 1; i<c.size();i++){ int l = c[i],r = s - 1; if (i!=c.size() - 1) r = c[i + 1] - 1; if (l <= t && t <= r) return c[i]; } return c[0]; } else{ //s - in for (int i = 1; i<c.size(); i++){ int l = s + 1,r = c[i]; if (i > 1) l = c[i - 1] + 1; if (l <= t && t <= r) return c[i]; } return c[0]; } }

Compilation message (stderr)

stations.cpp: In function 'void dfs(int, int, int)':
stations.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int j=0;j<vec[x].size();j++){
      |                  ~^~~~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=0;i<u.size();i++){
      |                  ~^~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:41:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int i = 1; i<c.size();i++){
      |                         ~^~~~~~~~~
stations.cpp:43:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             if (i!=c.size() - 1) r = c[i + 1] - 1;
      |                 ~^~~~~~~~~~~~~~
stations.cpp:51:26: 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(); 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...