Submission #955090

#TimeUsernameProblemLanguageResultExecution timeMemory
955090Trisanu_DasStations (IOI20_stations)C++17
Compilation error
0 ms0 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 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:55:52: error: a function-definition is not allowed here before '{' token
   55 | int find_next_station(int s, int t, vector<int> c) {
      |                                                    ^
stations.cpp:75:1: error: expected '}' at end of input
   75 | }
      | ^
stations.cpp:40:64: note: to match this '{'
   40 | vector<int> label(int n_, int k, vector<int> u, vector<int> v) {
      |                                                                ^