Submission #1102179

#TimeUsernameProblemLanguageResultExecution timeMemory
1102179hiepsimauhongUntitled (POI11_dyn)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int oo = 1e18; #define quickly ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0); #define print(a,l,r) for(int OK(l); OK <= r ; ++OK){ if(a[OK] < oo){cout << a[OK] <<' ';} else{cout << "- ";}} cout << '\n'; #define prints(a) for(auto i : a){ cout << i <<' ';} cout << '\n'; #define printz(a,l,r) for(int OK(1) ; OK <= l ; ++OK){for(int KO(1) ; KO <= r ; ++KO){if(a[OK][KO] < oo){cout << a[OK][KO] <<' ';}else{cout << "- ";}}cout << '\n';} cout << '\n'; #define fs first #define sd second #define ii pair<int, int> #define iii pair<int, ii> #define all(a) a.begin(), a.end() const int N = 3e5 + 5; const int mod = 1e9 + 7; const int lg = 17; int n, m, cnt(0); bool bom[N]; int mx_high[N]; vector<int> a[N]; void DFS(int u, int par, int mx){ if(cnt > m){ return; } mx_high[u] = 0; for(int v : g[u]){ if(v == par){ continue; } DFS(v, u, mx); mx_high[u] = max(mx_high[u], mx_high[v] + 1); } if(mx_high[u] > mx){ mx_high[u] = 0; ++cnt; } } signed main(){ quickly cin >> n >> m; for(int i(1) ; i <= n ; ++i){ cin >> bom[i]; } for(int i(1) ; i < n ; ++i){ int u, v; cin >> u >> v; a[u].push_back(v); a[v].push_back(u); } int l = 1, r = n; int ans = 0; while(l <= r){ int mid = (l + r) >> 1; cnt = 0; DFS(1, -1, mid); if(cnt > m){ l = mid + 1; } else{ r = mid - 1; ans = mid; } } cout << ans; }

Compilation message (stderr)

dyn.cpp:5:16: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
    5 | const int oo = 1e18;
      |                ^~~~
dyn.cpp: In function 'void DFS(int, int, int)':
dyn.cpp:31:19: error: 'g' was not declared in this scope
   31 |       for(int v : g[u]){
      |                   ^