Submission #1052359

#TimeUsernameProblemLanguageResultExecution timeMemory
1052359fuad27Stations (IOI20_stations)C++17
0 / 100
477 ms696 KiB
#include "stations.h" #include <bits/stdc++.h> using namespace std; const int N = 1010; vector<int> g[N]; int tin[N], tout[N], dp[N]; int tim=0, tim2=0; void dfs(int at, int p) { if(dp[at]) tin[at]=tim++; for(int to:g[at]) { if(to==p)continue; dp[to] = dp[at]^1; dfs(to, at); } if(!dp[at]) tout[at]=tim++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { std::vector<int> labels(n); for(int i = 0;i<=n;i++)g[i].clear(); tim=0; for(int i = 0;i<n-1;i++) { g[u[i]].push_back(v[i]); g[v[i]].push_back(u[i]); } dfs(0,0); for (int i = 0; i < n; i++) { if(dp[i])labels[i] = tin[i]; else labels[i] = tout[i]; // cout << i << " " << labels[i] << endl; } return labels; } int find_next_station(int s, int t, std::vector<int> c) { // sort(c.begin(), c.end()); if(c[0] >= s) { if(t < s) { return c.back(); } else { for(int i = 0;i<c.size();i++) { if(c[i] >= t)return c[i]; } } } else if(c.back() <= s) { if(t > s)return c[0]; for(int i = c.size()-1;i>=0;i--) { if(c[i] <= t) { return c[i]; } } } return 0; }

Compilation message (stderr)

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:45:19: 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++) {
      |                  ~^~~~~~~~~
#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...