Submission #955091

#TimeUsernameProblemLanguageResultExecution timeMemory
955091Trisanu_DasStations (IOI20_stations)C++17
76 / 100
596 ms35396 KiB
#include "stations.h" #include<bits/stdc++.h> using namespace std; #include <vector> #define pb push_back #define fi first #define se second #define pb push_back typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 5e5 + 5, oo = 1e18 + 7; int n; vector<int> Adj[N]; int l[N], r[N], d[N]; vector<int> vis; void dfs(int u, int p){ vis.pb(u); l[u] = vis.size(); for(auto v : Adj[u]){ if(v == p) continue; d[v] = d[u] + 1; dfs(v, u); vis.pb(u); } r[u] = vis.size(); } int tol[1005][1005]; ii tol2[600005]; vector<int> label(int n_, int k, vector<int> u, vector<int> v) { n = n_; vis.clear(); for(int i = 0; i < n; i++) Adj[i].clear(); for(int i = 0; i < (n - 1); i++){ Adj[u[i]].pb(v[i]); Adj[v[i]].pb(u[i]); } dfs(0, 0); vector<int> labels(n); for(int i = 0; i < n; i++){ if(!(d[i] & 1)) labels[i] = l[i]; else labels[i] = r[i]; } return labels; } int find_next_station(int s, int t, vector<int> c) { int mini = oo; for(auto it : c) mini = min(mini, it); if(mini < s){ for(int i = 1; i < c.size(); i++){ int le = c[i], ri; if(i != c.size() - 1) ri = c[i + 1] - 1; else ri = s; if(le <= t && ri >= t) return c[i]; } return c[0]; } else{\ for(int i = 0; (i + 1) < c.size(); i++){ int le = (i ? c[i - 1] + 1 : s + 1), ri = c[i]; if(le <= t && ri >= t) return c[i]; } return c.back(); } }

Compilation message (stderr)

stations.cpp:15:34: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   15 | const int N = 5e5 + 5, oo = 1e18 + 7;
      |                             ~~~~~^~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:63:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |   for(int i = 1; i < c.size(); i++){
      |                  ~~^~~~~~~~~~
stations.cpp:65:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |    if(i != c.size() - 1) ri = c[i + 1] - 1;
      |       ~~^~~~~~~~~~~~~~~
stations.cpp:72:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |   for(int i = 0; (i + 1) < 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...