제출 #563781

#제출 시각아이디문제언어결과실행 시간메모리
563781Leo121기지국 (IOI20_stations)C++14
컴파일 에러
0 ms0 KiB
#include "stations.h" #include <bits/stdc++.h> #include <vector> #define forn(i, a, b) for(int i = int(a); i <= int(b); ++ i) #define for0(i, n) for(int i = 0; i < int(n); ++ i) #define for1(i, n) for(int i = 1; i <= int(n); ++ i) #define pb push_back using namespace std; typedef vector<int> vi; const int maxn = 1e3; vi tree[maxn]; vi num; int cnt; void dfs(int u, int p, bool aux){ if(!aux){ num[u] = ++ cnt; } for(auto v : tree[u]){ if(v == p){ continue; } dfs(v, u, aux ^ 1); mayor[u] = mayor[v]; } if(aux){ num[u] = ++ cnt; } } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { num.clear(); num.resize(n); for0(i, maxn){ tree[i].clear(); } for0(i, n - 1){ tree[u[i]].pb(v[i]); tree[v[i]].pb(u[i]); } cnt = -1; dfs(0, 0, 0); return num; } int find_next_station(int s, int t, std::vector<int> c) { if((int) c.size() == 1){ return c[0]; } int li = 1, ls = c.size() - 1, mitad; if(!s){ while(li <= ls){ mitad = (li + ls) / 2; if(t > c[mitad - 1] && t <= c[mitad]){ return c[mitad]; } if(t > c[mitad]){ li = mitad + 1; } else{ ls = mitad - 1; } } return c[0]; } if(s > c[0]){ ls --; while(li <= ls){ mitad = (li + ls) / 2; if(t >= c[mitad] && t < c[mitad + 1]){ return c[mitad]; } if(t > c[mitad]){ li = mitad + 1; } else{ ls = mitad - 1; } } return (t >= c[(int) c.size() - 1] && t < s) ? c[(int) c.size() - 1] : c[0]; } ls --; while(li <= ls){ mitad = (li + ls) / 2; if(t <= c[mitad] && t > c[mitad - 1]){ return c[mitad]; } if(t > c[mitad]){ li = mitad + 1; } else{ ls = mitad - 1; } } return (t <= c[0] && t > s) ? c[0] : c[(int) c.size() - 1]; }

컴파일 시 표준 에러 (stderr) 메시지

stations.cpp: In function 'void dfs(int, int, bool)':
stations.cpp:28:9: error: 'mayor' was not declared in this scope
   28 |         mayor[u] = mayor[v];
      |         ^~~~~