Submission #349979

#TimeUsernameProblemLanguageResultExecution timeMemory
349979evnStations (IOI20_stations)C++14
69.87 / 100
1023 ms1260 KiB
#include <bits/stdc++.h> #include "stations.h" using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define sz(a) a.size() typedef long long ll; typedef pair<int, int> pii; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int timer = 0; int depth[1005]; int in[1005]; int out[1005]; vector<int> adj[1005]; vector<int> labels; void dfs(int u, int p){ if(depth[u] % 2 == 0)labels[u] = timer++; for(int v : adj[u]){ if(v != p){ depth[v] = depth[u]+1; dfs(v, u); } } if(depth[u] % 2 == 1)labels[u] = timer++; } vector<int> label(int n, int k, vector<int> u, vector<int> v) { labels.resize(n); for(int i = 0; i < n;i ++){ adj[i].clear(); depth[i] = 0; labels[i] = 0; } for(int i = 0; i < u.size(); i++){ int a, b; a = u[i]; b = v[i]; adj[a].pb(b); adj[b].pb(a); } dfs(0, -1); return labels; } int find_next_station(int s, int t, vector<int> c) { if(c.size() == 1)return c[0]; if(c[0] > s){ //this is the in value if(t < s || t >= c[c.size()-1])return c[c.size()-1]; for(int i = 0;i < c.size()-1; i++){ if(t <= c[i])return c[i]; } } else{ //this is the out value if(t <= c[0] || t > s)return c[0]; for(int i = c.size()-1; i >= 1; i--){ if(t >= c[i])return c[i]; } } }

Compilation message (stderr)

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   for(int i = 0;i < c.size()-1; i++){
      |                 ~~^~~~~~~~~~~~
stations.cpp:66:1: warning: control reaches end of non-void function [-Wreturn-type]
   66 | }
      | ^
#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...